arduino-course/Week 2/Photoresistor/Photoresistor.ino

16 lines
278 B
Arduino
Raw Normal View History

2019-11-15 23:54:28 +01:00
// Photoresistor
int sensorPIN = A0;
int LED = 9;
int sensorValue = 0;
int LEDValue = 0;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
sensorValue = analogRead(sensorPIN);
LEDValue = map(sensorValue, 0, 1023, 0, 255);
analogWrite(LED, LEDValue);
delay(100);
}