Controlling servo via serial monitor
i wanting able control servo motor via serial monitor. have tried simple sketch in online simulator 123d circuits , works fine. cannot work in real world. using arduino uno , have tried program arduino ide on mac , raspberry pi. ideas on why doesn't work? thanks.
-john
//begin code
#include <servo.h>
servo myservo;
void setup()
{
serial.begin(9600);
myservo.attach(4);
myservo.write(0);
}
void loop()
{
if(serial.available() > 0)
{
int data = serial.read();
if(data == 'a')
{
for(int = 0; i< 180; i++)
{
myservo.write(i);
delay(25);
}
}
}
}
-john
//begin code
#include <servo.h>
servo myservo;
void setup()
{
serial.begin(9600);
myservo.attach(4);
myservo.write(0);
}
void loop()
{
if(serial.available() > 0)
{
int data = serial.read();
if(data == 'a')
{
for(int = 0; i< 180; i++)
{
myservo.write(i);
delay(25);
}
}
}
}
i tried again , got work. don't know why didn't work other times tried.
Arduino Forum > Using Arduino > Project Guidance > Controlling servo via serial monitor
arduino
Comments
Post a Comment