Frankenbot
31/10/2018

Simple Frankenbot with lights and sound effect

By snorlaxprime

I was inspired by the cute Frankenbot papercraft from Instructables, so I thought why not make it truly alive by giving it some blinking lights and sounds effect. Here is the plan:

– Connect 2 LEDs for the eyes (different colours of course) and only one eye can be on at a time

– Connect 3 LEDs to the chest so that it can run lights left and right

– Play some scary halloween music for the full effect.

So here goes my Frankenbot ready for Halloween.

Step 1. Create the Frankenbot papercraft using the instruction from Instructables.

Step 2. Cut out the eye holes and insert LEDs

I use the recycle LEDs that was joined together with one 220 ohm resistor. Different legs was connected to the same resistor so only one eye will be on at a time, and you will have to switch the polarity to light up the second eye.

Step 3. Prepare the chest holes for LEDs

Cut out 3 more holes on the chest. It is much easier to cut it out when you had the robot chest disassembled.

Step 4. Prepare the electronics

I am using the recycled electronics from the “Light Activated MP3 player” from the earlier post. You can follow the link to find the instruction on how to build one.

Things to note, the way the light activated will need to be reversed, in this we want the Frankenbot to stay idle when there is sufficient light detected by the sensor, and when the light is off, it will came alive blinking it’s eyes and the chest lights and also playing the horror music at the background. So minor modification to the source code is necessary.

Step 5. Connecting the LEDs

What I had done here is essentially as follows:

– Eyes is connected through pin D2 and D6

– Chest LEDs is connected through pin D3, D4 and D5

So the following additional modification to the code is necessary

const int LDRpin = A0;       // LDR connected to pin A0 const int EyeCommon = 6;    // low = off
const int Eyepin = 2;      // Eye LED pin D23
const int Chest1 = 3;
const int Chest2 = 4;
const int Chest3 = 5;

Step 6. It’s Alive

There are several final modification to the code is necessary as follows:

In the setup section add the following:

pinMode(LDRpin, INPUT);     // setup LDR
  pinMode(EyeCommon, OUTPUT);
  pinMode(Eyepin, OUTPUT);
  pinMode(Chest1, OUTPUT);
  pinMode(Chest2, OUTPUT);
  pinMode(Chest3, OUTPUT);
mp3.playFolderTrack(7,Song);

in the loop section add the following:

if (ldrStatus <300){
    //digitalWrite(LED_BUILTIN, LOW);
    digitalWrite(EyeCommon, LOW);  // eye LED had different polarity so that 
    digitalWrite(Eyepin, HIGH);	   // only one eyes can be on at one time
    delay(100);
    digitalWrite(EyeCommon, HIGH);
    digitalWrite(Eyepin, LOW);
    timeoutTimer ++;
    //Serial.print("LED Light");
    if (DEBUG) Serial.println(timeoutTimer);
    mp3.start();
    digitalWrite(Chest1, LOW); // chest LED had common cable connected, 	 	
    digitalWrite(Chest2, HIGH); // my common cable is connected to Anode, 
    digitalWrite(Chest3, HIGH);  // so EyeCommon needs to be HIGH
    delay(100);
    digitalWrite(Chest1, HIGH);
    digitalWrite(Chest2, LOW);
    digitalWrite(Chest3, HIGH);
    delay(100);
    digitalWrite(Chest1, HIGH);
    digitalWrite(Chest2, HIGH);
    digitalWrite(Chest3, LOW);
    delay(100);
    digitalWrite(Chest1, HIGH);
    digitalWrite(Chest2, LOW);
    digitalWrite(Chest3, HIGH);
    delay(100);
    
    onStatus = true;
    if (timeoutTimer > 200) {
      if (DEBUG) Serial.println(timeoutTimer);
      timeoutTimer = 0;
      resetCount = 0;
    } 
  }

The section above is when the light intensity is low, so we flicker the eyes LED and the chest LEDs. The following section is when the light is high, we only have one eyes turned on.

} else {
    digitalWrite(EyeCommon, LOW);
    digitalWrite(Eyepin, HIGH);
    digitalWrite(Chest1, HIGH);
    digitalWrite(Chest2, HIGH);
    digitalWrite(Chest3, HIGH);    

    mp3.pause();
    timeoutTimer ++;
 }

And don’t forget to upload the scary scene music to the sd card. In this example I put it in the folder “07” and the song is called “001.mp3”

Now upload the code and test it, if all goes well, when you flick the switch your Frankenbot will come alive. Cover the sensor or turn off the lights, it’s eyes should flicker and the chest LED will flicker too.

Enjoy and Happy Halloween!!!

If you like this you can subscribe for frequent update and leave some comments.