LED Module

LED module

TECHNICAL SPECIFICATIONS

  • Colors: red / green / yellow.
  • LED pitch: 2.54 mm.
  • Resistor: 330 Ω.

Description

An LED (light-emitting diode) is a semiconductor device that emits light when electric current flows through it in the forward direction.

The LED module can provide a visual indication that an event has occurred, illuminate a project, or help check whether a program is working correctly.

Connection

The module uses a standard 3-pin connector and can be connected to any OUT port on the Trackduino controller.

Programming

The LED block used to work with the module is in the Actuators block group.

Block and generated functionDescription
LED block

void led (int port, bool state)
Turns the LED on at full brightness or turns it off on the specified port.

Arguments:
port (int port) — the port connected to the LED module.
state (bool state) — the on/off state.
LED brightness block

void ledPWM (int port, int PWM)
Sets the LED brightness by generating a PWM signal on the port.

Arguments:
port (int port) — the port connected to the LED module.
brightness (int PWM) — brightness level from 0 to 255.

Project example

Running lights

Running lights

Generated code:

void setup()
{
  pinMode( OUT1 , OUTPUT );
  pinMode( OUT2 , OUTPUT );
  pinMode( OUT3 , OUTPUT );
}

void loop()
{
  led ( OUT1 , HIGH );
  delay( 200 );
  led ( OUT2 , HIGH );
  delay( 200 );
  led ( OUT3 , HIGH );
  delay( 200 );
  led ( OUT1 , LOW );
  delay( 200 );
  led ( OUT2 , LOW );
  delay( 200 );
  led ( OUT3 , LOW );
  delay( 200 );
}