Thinking Digital 2010 kicked off with a choice of fabulous pre-conference workshops covering compelling topics such as web video, visual communication, origami and pitching. As a microcontroller enthusiast, I couldn’t help but choose the Arduino Power workshop run by Daniel Soltis of Tinker, Jamie Allen of Culture Lab and Brian Degger.
Most of the workshop attendees were new to Arduino, which was a good thing – Daniel and Jamie gave an overview of Arduino, its uses and some examples of cool projects.
We were each given a fantastic Oomlout ARDX starter kit – which is a great kit for anyone starting out or wants a nice kit with a variety of parts for projects, followed by a walk-through of a few simple sketches as a nice intro to Arduino, then let loose with various cogs, propellers, wire, balsa wood, glue guns and other bits to build and experiment with.
I created a dancing kitty, fashioned from balsa wood in conjunction with Arduino and a few bits of kit and a sketch – to become a simple example of how one can use a DC motor with a propeller to power a servo.
Here’s a little video of the simple whimsical kitty I made:
I’ve been asked to publish the sketch for this, and as all the wonderful libraries and examples in Processing are open source I’ve posted it below. As with all sketches, you can modify them to your needs or tweak the values to suit your project.
For example, you can experiment by changing one of the values in the sketch below to get the best turning response from the servo. So in line val = map(val, 0, 1023, 0, 179); – I changed ’1023′ to the maximum value I got from the DC motor when spinning the propeller – I tested this using another sketch and while spinning the propeller and reading the voltage which in my case was ’45′.
You can just about see the breadboard / arduino pin layout in this photo:
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
myservo.attach(9); // attaches the servo on pin 9 to the servo object
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 179); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
Many thanks to Daniel, Jamie & Brian for a fab afternoon of fun & lovely ARDX kit