I am intending to control the points/switches on a model train layout using multiple small RC servos and an arduino duemilanove. I have made a voltage splitter with rows of 3 double pole double throw switches . I intend to use the AnalogRead function to read the position of the switches, and control the servos in an all or nothing kind of fashion below is the output of the voltage splitter using analogSerial , 0 indicates switch left, 1 indicates switch right.
Switch Left=o Digital
ooo 1023
ool 551
olo 692
oll 219
loo 803
lol 329
llo 471
lll 0
I am starting with 1 splitter comprising 3 switches giving 8 combinations. This way I will control 3x3 servos on I/O pins with only a 3 analog pins using the SoftwareServo library.
Till I get things working I am just writing a sketch for 3 switches and 3 servos.
I have not passed the verify stage yet, here is the error message
""In function 'void loop()':
error: request for member 'write' in 'Servo1', which is of non-class type 'int' At global scope: ""
Here is my sketch
#include <SoftwareServo.h>
int InPin1 = 1;
int Servo1 = 1;
int Servo2 = 2;
int Servo3 = 3;
int val123 = 0;
void setup ( )
{
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
int InputPin1 = (1) ;
}
void loop()
{
val123 = analogRead(InPin1);
if (val123 >= 1000 && InPin1 < 1023) //Switches LLL [glow]OK till here[/glow]
Servo1.write(1);
Servo2.write(1);
Servo3.write(1);}
else if (InputPin1 => 500 && InputPin1 < 590) //Switches LLR
{
servo write 1 = 1
servo write 2 = 1
servo write 3 = 178
else if (InputPin1 => 600 && InputPin1 < 750) //Switches LRL
{
servo write 1 = 1
servo write 2 = 178
servo write 3 = 1
else if (InputPin1 => 200 && InputPin1 < 280) //Switches LRR
{
servo write 1 = 1
servo write 2 = 178
servo write 3 = 178
else if (InputPin1 => 780 && InputPin1 < 820) //Switches RLL
{
servo write 1 = 178
servo write 2 = 1
servo write 3 = 1
else if (InputPin1 => 300 && InputPin1 < 360) //Switches RLR
servo write 1 = 178
servo write 2 = 1
servo write 3 = 178
else if (InputPin1 => 450 && InputPin1 < 490) //Switches RRL
servo write 1 = 178
servo write 2 = 178
servo write 3 = 1
else (InputPin1 => 0 && InputPin1 < 100) //Switches RRR
servo write 1 = 178
servo write 2 = 178
servo write 3 = 178
I am open to any suggestions of better ways to do this
Aim, control 11 servos using Duemilanova, 3x3 on voltage splitters, 1 on a single switch voltage splitter and 1 on a pot.