Created
September 12, 2017 13:28
-
-
Save litan/95683f4f37a27502dd42550974c89a02 to your computer and use it in GitHub Desktop.
Controlling an arduino board
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // #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