Arduino and Photoresistor Data Readings
// Watch video here: https://www.youtube.com/watch?v=cwXXEmzg744
int Photoresistor= A0; //connect to analog pin A0
int Output;
int Led = 2;
void setup(){
Serial.begin(9600); // Communication speed
pinMode(Led, OUTPUT);
}
void loop(){
Output = analogRead(Photoresistor);
Serial.println(Output);
if (Output>800) {
digitalWrite(Led, HIGH);
}
else {
digitalWrite(Led, LOW);
}
delay(50); // Slow down the output for easier reading
}
No comments:
Post a Comment