Simple LED output
Very simple! The orange LED is turned ON when the code running on the Teensy MCU generates a HIGH output on the digital output pin 13 (check this connection on the block diagram).
Note that a digital pin can function as an input or an output. As the software developer, you must ensure that the very important task of hardware INITIALISATION is performed at the start of your code.
Open and upload the sketch TeensyLED_V0.ino. The orange LED on the Teensy board should blink at around 1 second intervals.
-
Change the blink rate to 5 flashes per second. Note the delay values that were used.
-
Note from Figure 1 that the RGB LED is attached to digital output pins 3,4,5. Blink the RED LED at 0.5 second intervals.
-
Expand the program to sequence through R > G > B at 1 second intervals. What did you learn about turning an LED ON and OFF?
Hint
A quick and useful way to experiment with code is to cut-and-paste existing lines and then comment out the lines not in use. New code can then be created by modifying the pasted code. The benefit of this approach is that the new and the old can be directly compared and it is relatively easy to switch back to the original version when things go wrong – and they will go wrong! This approach is particularly useful in the Arduino IDE environment where every new variant of code requires a separate sketch folder. This gets messy very quickly – way too many folders and too difficult to manage!
Remember to document and save all your code. The programming techniques used here are used again in later case studies and tasks. Excuses of lost code are not acceptable under any circumstances.
Outcomes
Upon completion of this task you should the basic skills to set up and use the Arduino IDE. In terms of coding skills you should understand the basic template code and how to make minor changes. Creating new solutions is something we still have to work on. This task covers basic digital output: the next task lets you analyse a more complicated GPIO interface.