Update: 2th Sept 2015. I came across this reasonable looking site talking about Servo’s: http://www.robotplatform.com/knowledge/servo/servo_tutorial.html. You may like to check it out later.Another useful page is by Ganesh Selvaraj who uses a 555 to control a servo – this approach is a manual way to control the servo. For wireless control, a 555 isn’t suitable because the 555 doesn’t accept anything other than different physical values of resistance and capacitance to control the pulses which ‘drive’ the servo. But static machines, the 555 approach is quite good. Ganesh’s page: http://www.engineersgarage.com/contribution/expert/servo-motor-control-using-555-timer-ic. End of update.
Sadly things kept getting in the way of electronics class 😦
But it was always my intention that you could use kit to explore on your own, using the manual as a head start, in addition to what we did in class and from what you get on the internet… and the open source Arduino micro-controller is very well supported on the web (as are electronic knowledge sites in general).
This is one of the things I wanted to go build with you in class. It’s pretty cool and gives a foundation in robotics. You can position the angle of a servo motor’s arm using an variable resistor (a ‘pot’). I love this, “feeling the connection” between the motor arm turning in direct response to the me turning the pot. 😀
When the Bluetooth modules arrive (the package was somehow sent back to China!!!) then we can do it wireless! 🙂
That will be cool. 🙂
Special thanks to the great tutorials by Jeremy Blum which very much helped in the creation of this project.
I’m sure I gave you a potentiometer and I definitely remember giving you a mini-servo. If you don’t have the 0.1uF and 33uF capacitors then you can probably leave them off, but I do think you have a 0.1uF and a 10uF, so maybe you can use them (even though their action may be of a lesser effect. Remember to observe the polarity – i.e. connect them the right way around.
I am using an LED to visually indicate when the +5V line is active (the line that the “powers” the pot and also the arduino), to remind me to turn it off via a button (a ‘latching switch’ type button) when not in use. A better visual indicator would have been a flashing LED – which could have been made to flash by the arduino. The pot, arduino and voltage regulator all drain the battery (because if provides the flow of current) so best switch it off when not in use. Lets briefly consider this. If the pot’s dial was turned and left in a position where it has it’s maximum 10K resistance, the current flowing through it is given by I=V/R = 5 volts / 10,000 ohms = 0.5mA which is pretty small but if turned and left in a a position where the resistance was only 100 ohms, then the current flow is 5V / 100 ohms = 50 mA. OK this number isn’t terribly big, but it’s there and to too much of a ‘nagging’ issue (i.e. wasting) for my liking. As mentioned, the arduino is also sucking power away from the battery providing the +5V, as is the voltage regulat which ‘burns’ off the excess voltage as heat (touch it, you may feel some warmth). Reports vary, but arduino power consumption is about 12 to 80 mA and the “LM7805” (voltage regulator) uses about 4mA, so it all adds up. and means battery replacement will occur sooner rather than later. It’s true the LED draws current (drains the battery) when on, but I feel that without the LED, I’d probably forget to disconnect the power and end up wasting more power.
You may need some long jumpers for this project. Maybe you can use ordinary jumpers and a crocodile clip to get extra length. Well, you can ask me for long wires tomorrow until Saturday. I can cut you some long jumper wire.
Realistic Schematic (may may need to save it / zoom in on it):
Code (you can just copy and paste it into your Arduino programming environment)
// Using a pot on A0 to control a mini-servo
// may get poor results if servo not powered enough.
// make sure power into the voltage regulator is > 7V
// so that you don’t get brown-outs from the output of
// the regulator.
// Make sure there’s a common ground for all devices.
// I have nothing connected to AREF (analog reference)
// You can use either one of the ‘GND’ (ground) connection on the arduino,
// I’m using the one beside “V in” but I think all GND’s are connected together.
// Remember all grounds for everything are connected togtther
// –> the common ground.
// I am using the other voltage regulator to power the arduino,
// an LED to show when the power is on, and that power supply
// goes through the pot’s RHS. The central “wiper-pin” on the pot
// goes to A0 (analog input zero) on the arduino, and the LHS
// pin on th pot goes to ground.
// (note: a little bit of power will go from RHS to LHS(ground)
// The arduino’s Volt.reg. has no ‘smoothing’ caps on it but the
// servo’s volt reg does. It’s got a 0.1uF polarised cap between
// the input of the volt reg and ground central pin. There is
// another cap 33uF polarised cap between the +5V output
// and ground
//Include Servo Library
int servoPin = 9;
int potPin = 0;
//Create Servo Object
jbServo.attach(servoPin); //Attaches the Servo to our object
// see Video 4 part C, http://www.jeremyblum.com/2011/01/24/arduino-tutorial-4-analog-inputs/
int AnalogPin9Value = analogRead(potPin);
constrain(AnalogPin9Value, 1, 1023);
AnalogPin9Value = map(AnalogPin9Value,1,1023,1,180);