I got the Sidekick Basic Kit for Arduino today which came with a bunch of different things but I'm trying to control the servo with a slide switch. This particular slide switch has 6 pins, 3 on each side. Can anyone help me out? I'm not really sure how to do any of it.
Simple servo test code that has basic button functions you can test just by touching the pin wires to ground. Note that servos may not work well when powered from the arduino.
//zoomkat servo button test 12-29-2011
#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;
void setup()
{
pinMode(button1, INPUT);
pinMode(button2, INPUT);
servo1.attach(7);
digitalWrite(4, HIGH); //enable pullups to make pin high
digitalWrite(5, HIGH); //enable pullups to make pin high
}
void loop()
{
press1 = digitalRead(button1);
if (press1 == LOW)
{
servo1.write(170);
}
press2 = digitalRead(button2);
if (press2 == LOW)
{
servo1.write(10);
}
}
Without wishing to cause offence saying you want to control a servo with a switch is no more informative than saying you want to control it with electricity.
What do you want to make the servo do, and what role do you have in mind for the switch?
I suspect that the switch you mention is a DPDT (Double Pole Double Throw) switch which should give you something the Google for more info.
...R