ATtiny 85 Strange program issue
hey guys, have gotten attiny85 , figured out how program , everyhting, simple program i'm trying use isn't working. code suppost read voltage of pin #2 , turn led on if below 3.5 volts. doing however, gets power turns led on. ideas why isn't working? thanks
code: [select]
int batterypin = 2;
int ledpin = 3;
float batteryvoltage = 0.0;
void setup() {
pinmode(ledpin, output);
pinmode(batterypin, input);
}
void loop() {
batteryvoltage = (analogread(batterypin)) * (5.0 / 1023.0);
delay(5);
if (batteryvoltage <= 3.5){
digitalwrite(ledpin, high);
}
else {
digitalwrite(ledpin, low);
}
}
hey guys, have gotten attiny85 , figured out how program , everyhting, simple program i'm trying use isn't working. code suppost read voltage of pin #2 , turn led on if below 3.5 volts. doing however, gets power turns led on. ideas why isn't working? thanksyou're sure pin supports analog input?code: [select]
int batterypin = 2;
int ledpin = 3;
float batteryvoltage = 0.0;
void setup() {
pinmode(ledpin, output);
pinmode(batterypin, input);
}
void loop() {
batteryvoltage = (analogread(batterypin)) * (5.0 / 1023.0);
delay(5);
if (batteryvoltage <= 3.5){
digitalwrite(ledpin, high);
}
else {
digitalwrite(ledpin, low);
}
}
Arduino Forum > Using Arduino > Project Guidance > ATtiny 85 Strange program issue
arduino
Comments
Post a Comment