This tutorial has been especially created to accompany the starterskit containing a Teensy microcontroller.

It will cover most of the basic skills and help to get you started with electronics.

During this tutorial you will be creating an interactive light; responding to approaching objects.
It advisable to work in small teams.

note:
The Teensy is to a large extend compatible with Arduino programs but much more powerful compared to for example an Arduino Uno. It uses the same integrated development environment (IDE) as the Arduino but with an extra add-on called Teensyduino.

Before you can start you have to make sure you have the Arduino IDE software installed on your laptop. To do so, follow the instructions on either of the following links:

After this install Teensyduino by following the instruction on the following link
https://www.pjrc.com/teensy/td_download.html

## Step 1 – actuator

In electronics components are distinguished into different groups.
Components which can perform an action are called actuators.
Within the interactive light an LED is used as the actuator.
The LED needs to be connected to the Teensy as shown in the schematic below.

Keep in mind that LED’s have a polarity. The cathode, or the minus side, is the flat side of the LED.

LEDs get damaged when their power rating  is exceeded (25 mA, see datasheet). The Teensy gets damaged when its pin maximum output current (10 mA) is exceeded. To prevent this from happening we need a resistor.

The value of this resistor can be determined by Ohm’s law.

$\displaystyle R = \frac{U}{I}$

U The voltage difference across the resistor is equal to the voltage provided by the Teensy (3.3 V) minus the voltage difference which is required across the LED (2.25 V for a red LED, see its datasheet).

I The current through the circuit is equal to the maximum acceptable current (10mA due to the Teensy).

$\displaystyle R_1 = \frac{3.3 V – 2.25 V}{0.010 A}$

This gives a value of 105 Ω (ohm)  for R1. As it is safer to use a somewhat larger resistor value, in this case we will use the 150 Ω resistor from the kit. This will lead to a current of around 7 mA which is safe for the Teensy and still sufficient to light the LED. This value can be identified by the coloured bands on the resistor.

To find the correct layout of the pins you may use the following simplified pin layout diagram or use the complete but more complex version from the website (see sidebar).

You can easily connect the components by using the breadboard that came with the E-Lucid starterskit. At the end of step 1 you should have something looking like this:

## Step 2 – sensor

Components which can sense are called sensors. In the interactive light we will use a proximity sensor. This sensor consists out of two parts; an infrared LED and an infrared phototransistor combined in a single housing.

When an object is close enough the infrared light emitted by the infrared LED is reflected into the phototransistor causing it to start conducting which in turn leads to a low instead of a high signal at its collector C. Hence an object is detected.

The sensor needs to be connected like shown in the schematic below. With R2 and R3 having a value of respectively 1 kΩ and 150 Ω.

However the sensor can’t be put directly into the breadboard. Therefore some wires need to be soldered to its legs first. Here you can read how to solder properly.

The final breadboard layout could look like the below image.

## Step 3 – code

The final step in creating the interactive light is to connect the input from the sensor to the output of the actuator.
This is done in code. You can download the code below.

Within the code you can find comments explaining it. Comments are lines preceded by “ // “. These lines are ignored when the code gets compiled and uploaded to the Teensy but are useful to make code readable. Take a look at the comments in the code.

Before uploading the code to your Teensy, set the board and port at the correct settings in the Arduino IDE (Tools/Board and Tools/Port).

Download the code below and upload it to your Teensy.
Also try to open the serial monitor or experiment with the code to change the behaviour of the light.