i want to output HIGH on an LED if the analog input receives < 0.20volts and LOW if it receives > 0.20v..meaning if 0.10 or 0.15 or 0 is inputted on the analog input..the LED in pin13 will light up..i have read somewhere that 40 is the equivalent voltage for 0.20v
i got that 0.20v from a comparator, lm339 to be exact.. it outputs 0.20v or 4.2v..and that output from the comparator is inputted to the analog input of arduino..ive tried the code below..when i use potentiometer as the input in arduino it works however when the output from the comparator is used it wont work..
this is the code..
int sensorPin = A0; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int sensorValue = 0; // value output to the PWM (analog out)
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue, DEC);
delay(0);
if(sensorValue > 41){
// turn the ledPin on
digitalWrite(ledPin, HIGH);
// stop the program for <sensorValue> milliseconds:
delay(0); }
if(sensorValue < 41){
// turn the ledPin off:
digitalWrite(ledPin, LOW);
// stop the program for for <sensorValue> milliseconds:
delay(0); }
}
anyone?...