I have been trying to learn to program over the past couple years. I had a class on C++ when I was in college but I hated it and as a EE student I figured it wasn't that important. Dumb move!
Now that I'm self employed I'm trying to get better at automation for my little shop, anyways, I have been messing with this program (example) for a while.
I had float points working at one point bt for some reason it's not working now. Any ideas what could be wrong here?
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
float pos = 0; // variable to store the servo position
float left = 85;
float right = 65;
float posinc = 1;
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = right; pos < left; pos += posinc) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(60); // waits 15ms for the servo to reach the position
}
for(pos = left; pos>=right; pos-=posinc) // goes from 180 degrees to 0 degrees
{
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(60); // waits 15ms for the servo to reach the position
}
}