Blink and pulse digital pins for LEDs, relays, indicators, and simple actuators.
Open in compiler →/*
Roboda verified Arduino sample 0976
Feature: Digital Output
Generated for online build, classroom practice, and hardware upload testing.
*/
const byte ledPin = 8;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH);
delay(185);
digitalWrite(ledPin, LOW);
delay(185);
}
How it works
Turn a digital output on and off for an LED, relay module, or simple indicator.
- Connect the LED/resistor or module input to ledPin.
- Set ledPin as OUTPUT in setup().
- Use digitalWrite(HIGH) and digitalWrite(LOW) in loop().
- Change the two delay() values to control blink speed.
Connections
| Pin | Connect to | Note |
|---|---|---|
| D8 | LED through 220-330 ohm resistor, relay module input, or indicator | Do not connect a bare load directly to an Arduino pin. |