Little Bird Curriculum / code littlebird.com.au
eagled-button-3d.ino Arduino (C/C++) 14 lines · 0 views ✦ Open in English IDE Raw Download Embed view
const byte BUTTON_PIN = 2;
const byte EYE_PIN = 3;
void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(EYE_PIN, OUTPUT);
  Serial.begin(9600);
}
void loop() {
  bool pressed = digitalRead(BUTTON_PIN) == LOW;
  digitalWrite(EYE_PIN, pressed ? HIGH : LOW);
  Serial.print("button:"); Serial.print(pressed ? 1 : 0);
  Serial.print(",eye:"); Serial.println(pressed ? 1 : 0);
  delay(20);
}

Embed this snippet

As an iframe:

Or drop it inline with a script tag (injects the highlighted block where included):

Shared from Little Bird Electronics curriculum.

Copied to clipboard