Create a device that will blink a Light-emitting-diode (LED) at a rate of 1Hz. You should be able to modify the blink rate in software.
In this lab you will learn the following:
Read all of the directions for Part 1 before doing
ANYTHING. Often the next step reveals why the current one is important.
First, we will test the Teensy 3.1 board:
The board comes pre-loaded with a 1-second blinker program. Plug in the USB cable to an active port, and plug in the Teensy. The amber LED should blink.
Next, find the header strip from the Teensy bag:
Next, snap apart the header to obtain 2 strips of 14 contacts.
Mount them in your wireless prototyping board with a spacing to fit the Teensy board (rows C and G work well).
Long pins should go into the protoboard:
Next, Fit the Teensy board on the pins:
Now, solder the pins to the board. Briefly heat the pin and pad, and then apply the solder so that it flows around the pin:
The completed board should look like this:
Now test it to see that it still blinks. If not, ask for help.
Start the Arduino application by clicking the desktop icon. The Arduino IDE has the following features:
Under File >Examples>Teensy>Tutorial1 select Blink:
That opens the arduino sketch with the Blink source code. You need to check that the correct board is selected, under Tools>Board>Teensy 3.1:
Now select the correct serial port (it may have some different name depending on your PC):
Check the value in the Blink program you just opened for the definition of const int ledPin. Referring to the card that came with your Teensy, change the value to the pin number for the LED.
Now, compile and load the program by clicking on the green right arrow at the top of the Arduino IDE. The first time the program loads to the board you may have to push rhe reset button on the Teensy, but normally this will happen automatically.
More information on this is found here.
Now, look at the program code, and see if you can speed up the blink rate. Demonstrate your new blink rate to a TA.
Now, save your changed sketch. THe system will require you to save the sketch in your own workspace, usually on your Z: drive. As a safety measure, you may want to back up your work to a thumb drive that you can use elsewhere.
Congratulations, you've just built and tested your first MK20DX256 application.
Question #1: What happened to the blink rate? Why?
Some background on using the Analog to digital converter in Arduino is here. Specific information on the Teensy 16 bit ADC module is here, in the technical specifications. Another source is Chapter 31, Analog-to-Digital Converter (ADC) in the processor manual.
Read all of the directions for Part 3 before doing ANYTHING. Often the next step reveals why the current one is important.
Question #2: how many bits wide is the default ADC data output in the MK20DX256?
Question #3: How many bits do you need for the delay, and how do you calculate the delay?
Question #4: How do you change the sample width?