Hope this is allowed on here so apologies if not..I know nothing about arduinos so thought that I would come straight to the professionals! If anyone is looking for some extra cash...preferably local I'm looking for someone to help me write a program for a one off project to liven up my sister in laws ballon shop display that she works in. I've built a contraption that will control a servo via a rotary switch so need someone to write a sketch that will contain several different ( or as many that can be done on an uno ) routines. If you are interest I look forward to hearing from you.
Cheers
Routines to do what?
Hey!...just the basics for you I suppose..
0 to 90 slow
0 to 90 fast
0 to 180 slow
0 to 180 fast....and so on and so on ....and anything flashy you can do with the other ones.
Are you my man!!?
What you have explained so far sounds easy. Is there only one servo involved ?
Hey helibob it probably is easy to you but to be honest I've tried for the last few weeks to get my head round this but me and computers are not a good match!..my offer is all legit and am willing to pay for the help...are you local?
Hey sorry it wouldn't let me finish!...yes just one servo being controlled by the rotary switch..
Can I ask you what it mean by this post is locked and awol?
I am in Suffolk but distance does not really matter.
Can you please post more details of the hardware involved. Which Arduino board have you got ? What servo and how is the system to be powered ?
It sounds like you want the servo to provide different movements depending on the position of the rotary switch. Is that right ?
When you say 0 to 90 slow do you mean that the servo should move slowly from 0 to 90 degrees ? If so, what should happen then ?
Yep you have the jist..so I've got an arduino uno and a hi tech ha-5685mh digital super torque servo. The set up is at the mo both are powered by a np7-6 6v 7ah battery and the signal cable to the servo is connected to the common of the rotary switch. The signal cables from the arduino board are connected outputs of the rotary switch even thought I'm using them as inputs so now I can rotate the switch to choose which program from the arduino to run the servo.
All the sketches need to do is for example..
0 -90 slow pause then back to O
0-90 fast pause then back to 0
0-180 slow pause then back to 0
0-180 fast pause then back to o
Then on the remaining any other wizardry that you can do..
I've tried to do this myself with the libraries ect but don't have the time to spend on it...so if you need a wall built you pay a brickie!!
Cheers
How many positions does the rotary switch have ?
Morning. .the rotary switch is a twelve way but I dont need to use all of them I would like to have 8 settings but whatever you think is best.
I will knock up a small test program and instructions how to wire the switch and servo and post it here later today and we can take it from there.
OK - here we go for a test
Connect the first 3 switch contacts to pins 3, 4 and 5 of the Arduino
Connect the common switch contact to GND on the Arduino
Connect the servo negative wire to GND on the Arduino
Connect the servo signal wire to pin A5 on the Arduino
Connect the servo positive wire to positive on the battery. Note NOT 5V on the Arduino
Connect the negative terminal of the battery to GND on the Arduino.
Here is the test program
#include <Servo.h>
Servo theServo;
const byte switchPins[] = {3, 4, 5};
int numberOfInputs = sizeof(switchPins);
const byte servoPin = A5;
byte state = 0;
void setup()
{
Serial.begin(115200);
theServo.attach(servoPin);
for (int pin = 0; pin < numberOfInputs; pin++)
{
pinMode(switchPins[pin], INPUT_PULLUP);
}
}
void loop()
{
state = 0; //default state
for (int pin = 0; pin < numberOfInputs; pin++)
{
if (digitalRead(switchPins[pin]) == LOW)
{
state = pin;
}
}
switch (state)
{
case 0: //home
theServo.write(0);
break;
case 1: //slow 90
for (int pos = 0; pos <= 90; pos++)
{
theServo.write(pos);
delay(20); //adjust to change servo speed
}
for (int pos = 90; pos > 0; pos--)
{
theServo.write(pos);
delay(20); //adjust to change servo speed
}
break;
case 2: //fast 180 with pause
theServo.write(180);
delay(1000);
theServo.write(0);
delay(1000);
break;
}
}
Each of the 3 switch positions that you have wired should produce a different set of servo movements. Note that as currently written the servo will not change its movement pattern immediately but will finish the current one when the switch position is changed.
Let me know how you get on.
EDIT - corrected a couple of errors
OP informed by PM
Ohh my that looks sooo confussing!..unfortunately im at work at the mo but will try it as soon as I get back!..thank you so much for all your help..chat later
Cheers
It may initially look confusing because it uses programming techniques that you may not be familiar with such as arrays and switch/case but fundamentally all it does is to work out which switch is closed and executes different code depending on what it finds.
I will be interested to find out whether it works in practice because I don't currently have the hardware at hand to test it, so I await your feedback with interest.
Hey Bob ( I hope you don't mind me calling you that)..ok I've rushed home from work programed you sketch in..( really sorry to say) quick spelling mistake on the first "the servo" but I managed to get that sorted!..but now an error message comes up with
"numberOfinputs" was not declared in this scope.....but I can't manage to sort that!
Any ideas please
Thanks
I've rushed home from work programed you sketch in..
If you copy/pasted it from my post above then there would not have been any spelling mistakes. Did you type it in ?
"numberOfinputs" was not declared in this scope.....
That's because the variable is actually called numberOfInputs
I just copied the code from my post into the IDE and it compiles OK.
Morning. Sorry got so excited must have rushed it in!..cool will try again when I get home and let you know...thanks again for all your help really appreciate it..
Need to get you some cash somehow as agreed
Thanks
Hey Ukhelebob! sorry but I couldn't find this thread anywhere and started to panic!..i asked on the forum for help and morganS put up the link.
I hope you are all ok
So I took your advice and asked a friend for help getting your sketch on my sketchboard and it loaded up perfectly first time!...ok I admit im a div and your a genius!
Ive been worrying all day as I couldn't find it...are we still ok to carry on with this?..morgan suggested doing it over email or the phone what do you think..up to you?
I'm not worried about getting paid for this so I am happy to carry on in the open forum as others may join in although we may use email at some time.
Have you wired the servo and switch as I suggested and run the code ?