View Single Post
Old 09-14-2008, 06:23 PM   #9 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location:
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
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
__________________
WINDMILLS DO NOT WORK THAT WAY!!!
  Reply With Quote