Skip to content

Instantly share code, notes, and snippets.

@litan
Created September 12, 2017 13:28
Embed
What would you like to do?
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