Skip to content

Arduino Intro

Kay Kasemir edited this page Sep 8, 2019 · 4 revisions

Arduino Intro

The Arduino is smaller, slower, simpler than the RoboRIO. It's very popular because of its low price and availability from many vendors. It has several inputs and outputs, arranged in a standard layout, which allows adding 'shields' for things like displays, motors etc.

For more, including the free programming environment, see https://www.arduino.cc

Compared to the RoboRIO, the Arduino can only be programmed in C/C++. The structure is actually similar to the RoboRio code with one function/method that's called to initialize, and another one that's called periodically.

A simple Arduino program looks like this:

// Connect an LED between the 'Gnd' and '13' pins of the Arduino

// 'setup' is executed once, like 'robotInit()'
void setup()
{
  // Configure pin 13 as output
  pinMode(13, OUTPUT);
}

// 'loop' is like the 'robotPeriodic()'
void loop()
{
  // Turn LED on
  digitalWrite(13, HIGH);
  // Wait half a second, 0.5 s, 500 ms
  delay(500);
  // Turn LED off
  digitalWrite(13, LOW);
  // Wait one second
  delay(1000);
}

While C/C++ and Java are different programming languages, the syntax of Control structures is practically identical, so we'll use an Arduino connected to RGB LEDs to play with for (...) loops.

For more Arduino examples, see https://github.com/team2393/Arduino

Clone this wiki locally