finyuk2005
Member
- Messages
- 637
so i have the nano every now, and have been testing it with a pair of power supplies,
seems to be working, but I am just getting a constant 5v on my output pin regardless of the voltage on the input pin.
im guessing i am just missing something fairly simple in the program?
const int analogPin = A0;
const int outputPin = 2;
const int threshold = 1.8; (i was just using 1.8 as in volts, as a test to start with)
void setup() {
pinMode(outputPin, OUTPUT);
}
void loop() {
int analogValue = analogRead(analogPin);
if (analogValue > threshold) {
digitalWrite(outputPin, HIGH);
}
else {
digitalWrite (outputPin, LOW);
}
}
have i got too many of the brackets "}" ?
im sure its something pretty simple!
cheers
seems to be working, but I am just getting a constant 5v on my output pin regardless of the voltage on the input pin.
im guessing i am just missing something fairly simple in the program?
const int analogPin = A0;
const int outputPin = 2;
const int threshold = 1.8; (i was just using 1.8 as in volts, as a test to start with)
void setup() {
pinMode(outputPin, OUTPUT);
}
void loop() {
int analogValue = analogRead(analogPin);
if (analogValue > threshold) {
digitalWrite(outputPin, HIGH);
}
else {
digitalWrite (outputPin, LOW);
}
}
have i got too many of the brackets "}" ?
im sure its something pretty simple!
cheers