Warning: Use of undefined constant PREG_PATTERN_VALID_LANGUAGE - assumed 'PREG_PATTERN_VALID_LANGUAGE' (this will throw an Error in a future version of PHP) in
/var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line
633
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in
/var/www/kucjica/emperors-wiki/inc/parser/xhtml.php on line
633
MOVEMENT serialread > arduino
#include <Servo.h>
Servo emperor; // create servo object
int incomingByte = 0; // for reading incoming serial data
int data = 11; // define data pin
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
emperor.attach(data);
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
// turn the servo in the direction of received data:
// 0-90 spin counter-clockwise
// 90 stop
// 90-180 spin clockwise
emperor.write(incomingByte);
}
}