just for fun here is my attempt at a working program, no ownership implied
Code:
int val = 0;
unsigned long time;
boolean overboost;
void setup(){
pinMode(0, OUTPUT);//don't need to set pin 3 for analogRead
}
void loop() {
overboost=false;
val=analogRead(3); //
//val should be between 204 and 716, 1v and 3.5v
val=val-204;// val between 0 and 512
if(val<0) val=0;
if(val>510){
val=510;
overboost=true;
}
val=val/10; //val between 0 and 51, just right for 1v pwm
if(overboost){
time=millis()%500;
if(time<250){
val=0; //turn off pwm for 250ms out of 500ms
// so the display flashes indicating overboost condition
}
}
analogWrite(0,val);
}
Binary sketch size: 1,460 bytes