A little curiosity. A whole lot of making.Robotics, CNC & connected ideas
robodatech.
Arduino sample library

Digital Output 38

Blink and pulse digital pins for LEDs, relays, indicators, and simple actuators.

Open in compiler →
/*
  Roboda verified Arduino sample 0926
  Feature: Digital Output
  Generated for online build, classroom practice, and hardware upload testing.
*/

const byte ledPin = 6;

void setup() {
  pinMode(ledPin, OUTPUT);
}

void loop() {
  digitalWrite(ledPin, HIGH);
  delay(115);
  digitalWrite(ledPin, LOW);
  delay(115);
}

How it works

Turn a digital output on and off for an LED, relay module, or simple indicator.

  1. Connect the LED/resistor or module input to ledPin.
  2. Set ledPin as OUTPUT in setup().
  3. Use digitalWrite(HIGH) and digitalWrite(LOW) in loop().
  4. Change the two delay() values to control blink speed.

Connections

PinConnect toNote
D6LED through 220-330 ohm resistor, relay module input, or indicatorDo not connect a bare load directly to an Arduino pin.

Good ideas start here.

Robotics lessons, build notes and useful updates. Subscribe by entering your email.