Modern Twist on Analog Dials

These days displays are all digital readouts or multifunction LCD screens that give you indications of pretty much everything that’s going on.  What seems to be lacking though is a good old fashioned analog dial with a needle pointing at a number.  Of course, a dial is normally limited to a single use, but I wanted to see if I could make something that’s the best of both worlds.

So, as with most of my projects, I started with a Xino Arduino clone from Ciseco.  Couple this with a cheap 9g servo from eBay and had a play about.

 

The servo is very small, with the main part of the body just 22 x 22 x 10mm.  They come with a selection of horns, one of which would do nicely as a pointer.

 

So, I found myself a suitably sized box (quite oversized actually, but this was only for testing purposes), and made a keyed hole for the servo to sit in.  Connecting it to an Arduino is very strait forward, needing just +5V, Ground and a single PWM pin.  The PWM pin gives pulses of 5V of a duration that is proportional to desired servo position; the longer the duration, the further round the dial will read.

Programming was very simple as the Arduino already has a Servo library, so I adapted one of the example sketches so that I could send a value between 0 and 20 over the serial port and the servo would move to represent that value.  The actual values were marked on the dial by hand once I knew where the needle was expecting to be pointing to.

 

#include <Servo.h> 

Servo myservo; // create servo object to control a servo 

int val; // variable to read the value from the analog pin
int servo = 0;
int index = 0;
char strval[3];
void setup()
{
 Serial.begin(9600);
 Serial.print("Begun");
 myservo.attach(9); // attaches the servo on pin 9 to the servo object
} 

void loop()
{
 if (Serial.available()){
 char ch = Serial.read();
 if (index < 2 && ch >= '0' && ch <= '9'){
 strval[index++] = ch;
 }
 else
 {
 strval[index]=0;
 val = atoi(strval);
 index = 0;
 Serial.println(val);
 }
 }
 if (val >= 0 && val <=20){ //Checks the value is between 0 and 20
 servo = map (val, 0, 20, 0, 179); //Converts the value to 180 degrees of servo movement
 }
 else
 {
 servo = 0;
 }

 myservo.write(servo); // sets the servo position according to the scaled value
 delay(150); // waits for the servo to get there
}

 

With the initial tests successful, the plan is to build a laser cut box that has 3 dials (Outside air temp, Inside air temp, Desired heating temp).  The Xino will connect to Pachube.com for the values to display.  In order to increase the range of each of the dials, there will be 2 or 3 gradients marked on them, with an LED illuminating the readings for the current range.  Watch this space to see how that goes…