This shows you the differences between two versions of the page.
move_serialread_arduino [2014/01/23 14:30] zoza created |
move_serialread_arduino [2014/01/23 14:31] (current) zoza |
||
---|---|---|---|
Line 16: | Line 16: | ||
} | } | ||
- | void loop() { | + | void loop() { |
- | // send data only when you receive data: | + | // send data only when you receive data: |
- | if (Serial.available() > 0) { | + | if (Serial.available() > 0) { |
- | // read the incoming byte: | + | // read the incoming byte: |
- | incomingByte = Serial.read(); | + | incomingByte = Serial.read(); |
- | + | ||
- | // turn the servo in the direction of received data: | + | // turn the servo in the direction of received data: |
- | // 0-90 spin counter-clockwise | + | // 0-90 spin counter-clockwise |
- | // 90 stop | + | // 90 stop |
- | // 90-180 spin clockwise | + | // 90-180 spin clockwise |
- | emperor.write(incomingByte); | + | emperor.write(incomingByte); |
- | } | + | |
} | } | ||
+ | } | ||
</code> | </code> |