Project

General

Profile

Up

Next

Modes of Operation

Each digital I/O pins of the board can be configured either as input or output. Output pins can be either digital (on / off), setup to generate a PWM at different frequencies or control a WS28XX RGB led.

Digital output

Digital output pins are set low by sending 0. Any other value in the range 1โ€‰โ€”โ€‰65535 sets it high.

PWM frequencies and resolution

Not all pins can do PWM. The following table summarizes the characteristics of each pins, for the supported boards

Table 1. Uno, Nano
Pin # Frequencies Resolution (bits)

3, 11

31kHz, 122Hz, 31Hz

8

5, 6

31kHz, 122Hz, 31Hz

8

9, 10

31kHz

8

122Hz

16

31Hz

15

Table 2. Mega 2560
Pin # Frequencies Resolution (bits)

4

31kHz, 122Hz, 31Hz

8

9, 10

31kHz, 122Hz, 31Hz

8

2, 3, 5-13, 44-46

31kHz

8

122Hz

16

31Hz

15

The PWM duty cycle is set proportionally to the 16 bits sent value: 0 represents 0% duty cycle (PWM off), 32767 would be 50% and 65535 is 100% duty cycle (PWM always high).

WS28XX RGB led

On each pin, up to 16 (chained) leds can be addressed (4 bits). Each color channel of each led is coded on 4 bits. The 16 bits value sent to the corresponding pin is interpreted according to the following table.

15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

Led #

Green

Red

Blue

For instance, 0xfff sets LED #0 to pure white, 0x1800 sets LED #1 to green at 50% instensity, etc.