2 - BASIC TRAINING - Control external LEDs with Arduino and Teensy

Video: https://youtu.be/5q04aPHSoVg

#Robotics #Drones #Arduino #Hardware #Teensy_4

Full code and manual on GitHub
Quadcopter frame PCB on OSHW lab

🔙 Previous Part | Next Part 🔜

↩️ Go Back

Table of Contents:


A) Introduction - External LEDs

Welcome to the second part of this video series where you'll learn how to build and program your own Teensy-controlled quadcopter.

In the previous video, you connected your Teensy microcontroller to your computer and uploaded your first program.

In this part, you will learn how your Teensy can control two external LEDs.

During the startup of your quadcopter, the red LED will light up to show that the quadcopter is still in its setup process.

When the setup process is finished, the green LED will light up, indicating that the quadcopter is ready to fly.


B) LEDs on a Breadboard (electric circuit)

Let's start this part by testing the electronic circuit on a solderless breadboard. First, you will connect two 100-ohm resistors to pins 5 and 6 of your Teensy using jumper wires. The resistors ensure that the current flows correctly through your LEDs. Pin 6 gives signals to the green LED, and pin 5 to the red LED.

The schematic view of the circuit is shown here:

B.1) Solder Teensy's pins and build the circuit

To connect your Teensy to the solderless breadboard, you need to solder male headers to its pins.

There are 14 pins on each side of the Teensy, so cut the male headers to the desired lengths.

Next, solder the male headers to the Teensy pins. To make the soldering process easier, you can fix the headers in the solderless breadboard. Just make sure you don't spill solder on the breadboard. Once you've soldered one pin, the other pins generally follow smoothly.

Now you are ready to build the circuit. Add the Teensy to the breadboard and continue with the LEDs. Notice that an LED has a long and a short leg.

The long leg represents the positive side, or anode, and should be connected to the resistor. The short leg is the negative side, or cathode, and should be connected to the negative bus line.

Connect the resistors in series with the positive side of each LED. Now, add the jumper wires to complete the circuit.


B.2) LED control - Arduino Program Example

Let's continue with the Arduino code to control the LEDs.

All Arduino sketches consist of both a setup and a loop part.

As seen in the previous part, you can control the internal orange Teensy LED with pin 13. Configure the pin as an output with the line pinMode, and use the line digitalWrite to give it the command HIGH. This will light up the orange LED, showing that the microcontroller is powered and working.

Use the same commands to control the external LEDs. You already connected the red LED to pin 5 to indicate that the setup process is ongoing. Light up the red LED by giving it the HIGH command.

Now wait 4 seconds, or 4,000 milliseconds, using the delay command to simulate the setup process.

To indicate that the setup process is finished, turn off the red LED using the command LOW, and subsequently turn on the green LED.

The code in the loop part runs continuously, but because you do not write any commands in this part, the green LED will remain illuminated as specified in the last line of the setup part.

Now, upload the new code to your Teensy and verify that all LEDs light up in the correct order.

Congratulations! You are now able to control two external LEDs.

This is the same principle used in our drone...

In the next video, you will learn how your Teensy can measure a voltage.


🔙 Previous Part | Next Part 🔜

↩️ Go Back


Z) 🗃️ Glossary

File Definition
Uncreated files Origin Note