arduino-course/Week 2/LED Intensity/LED Intensity.ino

16 lines
326 B
Arduino
Raw Permalink Normal View History

2019-11-15 23:54:13 +01:00
// LED Intensity Control
int LED = 9;
int intensity = 0;
int potentionmeterValue = 0;
int potentiometerPin = A0;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
potentionmeterValue = analogRead(potentiometerPin);
intensity = map(potentionmeterValue, 0, 1023, 0, 255);
analogWrite(LED, intensity);
delay(10);
}