Ok, so i got Arduino Uno starter kit yesterday.
I got to grips with a few example tutorials that came in the booklet.
So i thought, why not customise it?
so i tried to.
I used the code from the top of my head, comparing it to the example codes.
All it does, is when i press the button, the ServoMotor will move 180, stop and move 180 again, and repeat.
here is the code:
#include <Servo.h>
Servo myservo;
int pos = 0;
int switchPin = 8;
void setup(){
myservo.attach(3);
pinMode (switchPin, INPUT);
}
void loop(){
if(switchPin == LOW){
for(pos = 0; pos < 180; pos +=1)
{myservo.write(pos);
delay(15);
}
for(pos = 180; pos>=1; pos -=1)
{
myservo.write(pos);
delay(15);
}
}
}
I dont see any errors in that.
And i have wired it, so that:
Motor:
Black wire to ground - Yellow to 5v - White to Analogue 3 (because it has ' ~ ' next to it)
Switch:
In centre of the bread board (2 pins on one side, and 2 pins on the other, so none are on teh same row).
On the left side, one pin is connected to ground, and the other to digital pin 8.
Please take me easy, i am a total noob at this, i am learning new as i go along.
