View Single Post
Old 12-31-2013, 12:39 PM   #9 (permalink)
P-hack
Master EcoModder
 
P-hack's Avatar
 
Join Date: Oct 2012
Location: USA
Posts: 1,408

awesomer - '04 Toyota prius
Thanks: 102
Thanked 252 Times in 204 Posts
I hear from the discrete camp a lot, but having invested in micro-controllers I really see them as much simpler in terms of number of components used and cost, as well as flexibility.

A little more advanced, but apparently you can use arduino on an attiny45 (and use the arduino to program it). The wiring might be this simple, and a possible sketch (program), definitely worth looking at microcontrollers since one component can do the job and is like $0.50.
arduino on attiny




Code:
int val = 0; 
void setup()
{
pinMode(0, OUTPUT);
pinMode(3, INPUT);
}
void loop() {
  val=analogRead(3);
  //val=val - some constant (bench test for value) for base zero
  //val = val * another constant 
  //  to get full scale deflection of meter (bench test again)
  analogWrite(0,val);
}
edit, analogRead returns a value from 0-1023, for 0-5v respectively.
analogWrite takes a value from 0-255 (255=100% duty cycle ~ 5v), so you can probably calculate the needed constants.
Attached Thumbnails
Click image for larger version

Name:	Untitled.png
Views:	134
Size:	34.0 KB
ID:	14332  

Last edited by P-hack; 12-31-2013 at 01:03 PM..
  Reply With Quote