Arduino API

Implementation of the Arduino API in RIOT.

enum @176
INPUT
configure pin as input
OUTPUT
configure pin as output
INPUT_PULLUP
configure pin as input with pull-up resistor
enum @177
LOW = 0
pin is cleared
HIGH = 1
pin is set
SerialPort Serial()

Primary serial port (mapped to ARDUINO_UART_DEV)

void pinMode(int pin, int mode)

Configure a pin as either input or output.

Parameters

pin:pin to configure
mode:mode to set the pin to

void digitalWrite(int pin, int state)

Set the value for the given pin.

Parameters

pin:pin to set
state:HIGH or LOW

int digitalRead(int pin)

Read the current state of the given pin.

Parameters

pin:pin to read

Return values

  • state of the given pin, HIGH or LOW
void delay(unsigned long msec)

Sleep for a given amount of time [milliseconds].

Parameters

msec:number of milliseconds to sleep

void delayMicroseconds(unsigned long usec)

Sleep for a given amount of time [microseconds].

Parameters

usec:number of microseconds to sleep

unsigned long micros()

Returns the number of microseconds since start.

Return values

  • value of microseconds since start
int analogRead(int pin)

Read the current value of the given analog pin.

Parameters

pin:pin to read

Return values

  • a value between 0 to 1023 that is proportionnal to the voltage applied to the pin
ARDUINO_UART_DEV

UART device to use for Arduino serial.

1
UART_DEV(0)