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);
      }
    }
  }
}

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

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor