There's been some interest in an analog gauge lately here so I thought I'd put an example together. I've only run it on the bench, but it is a couple lines of code to spit out the current mpg (or whatever) on pwm pin 11.
I found a donor meter:
Took it apart, pried off the label plate:
Scanned in the plate and doctored it up in paintbrush:
Printed out the new label and carefully cut it out (used plate as template):
Glued the new label to the original label plate w/rubber glue, and glued the plate back with rubber glue. Hooked it up with a 4.7k resistor to pin 11 and ground.
slapped a test program together and played with maxv till I found a good value for full scale deflection. (had to swap meter leads when needle tried to move backwards)
Code:
void setup(){
pinMode(11,OUTPUT);
}
#define maxv 120
void loop(){
analogWrite(11,0);
delay(1000);
analogWrite(11,maxv/2);
delay(1000);
analogWrite(11,maxv);
delay(1000);
}
Confirmed that half scale deflection looked good also:
Making the new labeling was the hardest part