Analog input with condition

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

this code wont work.

/*
  
int sensorPin = A0;    
int ledPin = 13;      
int sensorValue = 0;  

void setup() {
 
  pinMode(ledPin, OUTPUT);  
}

void loop() {
  // read the value from the sensor:
  sensorValue = analogRead(sensorPin);    
  if(sensorValue > 40){
  // turn the ledPin on
  digitalWrite(ledPin, HIGH);  
  // stop the program for <sensorValue> milliseconds:
  delay(1000);        }
  if(sensorValue < 40){
  // turn the ledPin off:        
  digitalWrite(ledPin, LOW);   
  // stop the program for for <sensorValue> milliseconds:
  delay(1000);         }         
}
/* <-- this starts a comment, but where does it end?
 int sensorPin = A0;    
int ledPin = 13;      
int sensorValue = 0;

Your code is simply a comment

const int sensorPin = A0;    
const int ledPin = 13;      
const int THRESHOLD = 40;

void setup() 
{
  pinMode(ledPin, OUTPUT);
  digitalWrite (ledPin, LOW);
}

void loop() 
{
  digitalWrite (ledPin, analogRead(sensorPin) < THRESHOLD);    
  delay(1000);        }
}

it worked! :slight_smile:

now i want that output of the arduino to be inputted on an Programming language..VB.net to be exact..some say that is just using serial port..what will i code to send that output from arduino to vb.net..is it analog or digital that will be passed to vb.net?..

here is my code already..it will output high when the sensorvalue is less than 41

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){
    digitalWrite(ledPin, LOW);  
} else {
    digitalWrite(ledPin, HIGH);  
}       
delay(0);
  
}

Instead of using LED to the output..i want to send it to computer and later be read to VB.net..is it possible?..