You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.1 KiB
51 lines
1.1 KiB
|
|
#include <Wire.h>
|
|
#include <Adafruit_PWMServoDriver.h>
|
|
|
|
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
|
|
|
|
#define SERVOMIN 150 // this is the 'minimum' pulse length count (out of 4096)
|
|
#define SERVOMAX 600 // this is the 'maximum' pulse length count (out of 4096)
|
|
|
|
String inputString = ""; // a String to hold incoming data
|
|
boolean stringComplete = false; // whether the string is complete
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
|
|
pwm.begin();
|
|
pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
|
|
|
|
delay(10);
|
|
}
|
|
|
|
|
|
void loop() {
|
|
// print the string when a newline arrives:
|
|
if (stringComplete) {
|
|
Serial.println(inputString);
|
|
// clear the string:
|
|
inputString = "";
|
|
stringComplete = false;
|
|
}
|
|
}
|
|
|
|
void serialEvent() {
|
|
while (Serial.available()) {
|
|
// get the new byte:
|
|
char inChar = (char)Serial.read();
|
|
// add it to the inputString:
|
|
inputString += inChar;
|
|
// if the incoming character is a newline, set a flag so the main loop can
|
|
// do something about it:
|
|
if (inChar == '\n') {
|
|
stringComplete = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
void svuota(){
|
|
|
|
}
|
|
|
|
|