Skip to content

Instantly share code, notes, and snippets.

@litan
Created September 12, 2017 13:28
Show Gist options
  • Select an option

  • Save litan/95683f4f37a27502dd42550974c89a02 to your computer and use it in GitHub Desktop.

Select an option

Save litan/95683f4f37a27502dd42550974c89a02 to your computer and use it in GitHub Desktop.
Controlling an arduino board
// #include ~/kojo-includes/ka-bridge.kojo
def setup() {
pinMode(2, INPUT)
pinMode(3, OUTPUT)
pinMode(4, OUTPUT)
pinMode(5, OUTPUT)
}
def loop() {
val switchState = digitalRead(2)
if (switchState == LOW) {
digitalWrite(3, HIGH)
digitalWrite(4, LOW)
digitalWrite(5, LOW)
}
else {
digitalWrite(3, LOW)
digitalWrite(4, LOW)
digitalWrite(5, HIGH)
delay(250)
digitalWrite(4, HIGH)
digitalWrite(5, LOW)
delay(250)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment