Created
March 30, 2012 12:45
-
-
Save priithansen/2251279 to your computer and use it in GitHub Desktop.
Makibot Arduino code
This file contains 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
boolean stringComplete = false; // whether the string is complete | |
String inputString = ""; | |
void setup() { | |
// test pin | |
pinMode(10, OUTPUT); // Vasakule | |
pinMode(9, OUTPUT); // Paremale | |
// initialize serial: | |
Serial.begin(9600); | |
} | |
void loop() { | |
// print the string when a newline arrives: | |
if (stringComplete) { | |
if (inputString == "e") { | |
digitalWrite(10, HIGH); | |
digitalWrite(9, HIGH); | |
} | |
if (inputString == "v") { | |
digitalWrite(10, HIGH); | |
} | |
if (inputString == "p") { | |
digitalWrite(9, HIGH); | |
} | |
if (inputString == "s") { | |
digitalWrite(10, LOW); | |
digitalWrite(9, LOW); | |
} | |
inputString = ""; | |
stringComplete = false; | |
} | |
} | |
/* | |
SerialEvent occurs whenever a new data comes in the | |
hardware serial RX. This routine is run between each | |
time loop() runs, so using delay inside loop can delay | |
response. Multiple bytes of data may be available. | |
*/ | |
void serialEvent() { | |
while (Serial.available()) { | |
// get the new byte: | |
char suund = (char)Serial.read(); | |
inputString += suund; | |
stringComplete = true; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment