Skip to content

Teensyduino

Sean Ye edited this page Sep 15, 2016 · 15 revisions

Teensyduino is a small microcontroller which will act as the brain of your robot. In order to set up your board you will need to install two pieces of software.

  1. Arduino (follow the install links here) The software is free and you can donate if you wish.

  2. Teensyduino (follow the directions and make sure you've installed arduino and be sure to not have it running when you install)

Open the arduino application and in the upper right click Tools->Board->Teensy LC. This tells the arduino application which board we are using.

The teensyduino has a built-in light on it and our first program will be to turn the led light on and off at half second intervals.

The code is shown below and also in the code section here on github.

const int flash_pin = 13;

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

void loop() {
  digitalWrite(flash_pin, HIGH);
  delay(500);
  digitalWrite(flash_pin, LOW);
  delay(500);
}

Let's break this down line by line.

const int flash_pin = 13;

This line declares flash_pin as a variable, sort of like a variable named x in math. It provides us a way to easily access the number 13 later in the program. The reason flash_pin is 13 is because the teensyduino board has a light hard wired to this pin. We can create more lights later with some hardware.

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

This code is inside void setup() , where the code runs only once when the board gets power. pinMode(flash_pin,OUTPUT); tells the board that we want to treat pin 13 as an output instead of an input.

void loop() {
  digitalWrite(flash_pin, HIGH);
  delay(500);
  digitalWrite(flash_pin, LOW);
  delay(500);
}

Finally, void loop() runs over and over again. The digitalWrite tells the pin to switch on and then off with the delays in there to make sure there's time between the two states.

Once you've finished, plug in the teensyduino and press the upload button on the top.

Clone this wiki locally