int potPin = 0;
int ledPin = 9;
int val = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
val = analogRead(potPin);
digitalWrite(ledPin, HIGH);
delay(val);
digitalWrite(ledPin, LOW);
delay(val);
}
Alat dan Bahan
– Komputer
– Board arduino Uno r3
– Kabel USB
– Resistor 220
– Potensiometer 10K
– LED 5mm
– Breadboard
– Kabel
1. Rangkai alat dan bahan seperti skema
2. Tuliskan kode program pada arduino IDE
3. Upload Program
4. Tekan Potensiometer dan amati delay waktu nyala LED