Darcey's first Arduino Project

K2SO makes a better blink

Posted by Lotek on Thursday, 1st January 1970

Fresh on the back of seeing Rogue One with her brother, Darcey asked if she could make a robot. The result is her first Arduino project.

The logic is based upon the blink example bundled with the Arduino IDE, and the circuit features two independently wired LEDs, each with a corresponding resisitor, and its own driving pin on the microprocessor. Its built on a breadboard to keep things solder free.

I rigged up the first 'eye' to show her how to make the necessary connections. She built the second eye in isolation whilst I drew the robot and found a pencil to drill out the openings. We used constants in the code to refer to DARCEYS_LED and DADS_LED, so that she could reference the lines I'd written to make the wink and blink work. She very quickly understood the looping mechanism and effects of setting either pin in HIGH or LOW. 


Source Code

int DADS_LED = 5;
int DARCEYS_LED = 6;
void setup() {
  pinMode(DADS_LED,OUTPUT);
  pinMode(DARCEYS_LED, OUTPUT);
  Serial.begin(9600);
  Serial.println("Hello. I am K2-S0. Please wait while I get ready");
  for(int i=0;i<10;i++){
    Serial.println(20-i);
    delay(1000);
  }
}
void loop() {
  for(int i=0;i<10;i++){
    Serial.println(10-i);
    delay(1000);
  }
  
  //stare
  Serial.println("Wake up!");
  delay(2500);
  digitalWrite(DADS_LED,HIGH);
  digitalWrite(DARCEYS_LED,HIGH);
  delay(6000);
  //blink
  Serial.println("Blink");
  delay(2500);
  digitalWrite(DADS_LED,LOW);
  digitalWrite(DARCEYS_LED,LOW);
  delay(500);
  digitalWrite(DADS_LED,HIGH);
  digitalWrite(DARCEYS_LED,HIGH);
  delay(6000);
  //wink
  Serial.println("Wink!");
  delay(2500);
  digitalWrite(DADS_LED,LOW);
  digitalWrite(DARCEYS_LED,HIGH);
  delay(500);
  digitalWrite(DADS_LED,HIGH);
  digitalWrite(DARCEYS_LED,HIGH);
  delay(6000);
  //sleep
  Serial.println("go to bed!");
  delay(2500);
  digitalWrite(DADS_LED,LOW);
  digitalWrite(DARCEYS_LED,LOW);
  delay(3000);
}