Wednesday, January 22, 2014

Hacked Toy


 The toy has a single motor that allows the legs, arms, and head to move. I have a switch is used to send a signal to pin 12 on the Arduino a an input and then sends an output signal to pin 13 that allows the toy to dance around.



This is my hacked toy with fancy shoes with LEDs.

 Their is also a button switch that is used as an input on pin 6 and ten sends an output signal to pin 5 and lights up the LED lights on the toys shoes.


Here is my code:

#define LEDInput 6
#define LEDOutput 5
#define MotorInput 12
#define MotorOutput 13

void setup(){
  pinMode(LEDInput,INPUT_PULLUP);
  pinMode(LEDOutput,OUTPUT);
  pinMode( MotorInput,INPUT);
  pinMode(MotorOutput,OUTPUT);  
}

void loop(){
  
if(digitalRead( MotorInput)==HIGH){
    digitalWrite(MotorOutput,HIGH);}
  else{
  digitalWrite(MotorOutput,LOW);
  }
  
if(digitalRead(LEDInput)==LOW){
    digitalWrite(LEDOutput,HIGH);}
    else{
      digitalWrite(LEDOutput,LOW);
    }
}


No comments:

Post a Comment