Untitled
Anonymous
c_cpp
03/06/2023 6:49 AM
788 B
23
Indexable
int ledPin = 9;
void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop()
{
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue); // LDR sensor value
delay(50); //short delay for faster response to light.
if(sensorValue >= 700){
analogWrite(ledPin, 255);
delay(30);
}
if(sensorValue<=700)
{
analogWrite(ledPin, 0);
delay(30);
}
}
Editor is loading...