Go Down

Topic: CASH WAITING!!..Essex England  (Read 1 time) previous topic - next topic

Kai200

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

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Kai200

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!!?

UKHeliBob

What you have explained so far sounds easy.  Is there only one servo involved ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Kai200

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?

Kai200

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?

UKHeliBob

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 ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Kai200

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

UKHeliBob

How many positions does the rotary switch have ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Kai200

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.

UKHeliBob

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.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

UKHeliBob

#11
Feb 02, 2016, 11:48 am Last Edit: Feb 04, 2016, 04:54 pm by UKHeliBob
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
Code: [Select]

#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
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Kai200

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

UKHeliBob

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.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Kai200

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

Go Up