Initial version. Illuminates the LED when the user button is held down. Otherwise, the LED is off. Variation on 21_Button_v5.

Committer:
CSTritt
Date:
Tue Sep 21 02:00:55 2021 +0000
Revision:
108:eee3167b25b4
Parent:
107:61b9c99a4e27
Child:
109:b061f9830736
Initial 2021 mbed 5 version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
CSTritt 107:61b9c99a4e27 1 /*
CSTritt 108:eee3167b25b4 2 Project: BinaryCount
CSTritt 108:eee3167b25b4 3 File: main.cpp
CSTritt 108:eee3167b25b4 4
CSTritt 108:eee3167b25b4 5 Displays 8 bit binary count on bar graph display.
CSTritt 108:eee3167b25b4 6
CSTritt 108:eee3167b25b4 7 Written by: Dr. C. S. Tritt
CSTritt 108:eee3167b25b4 8 Created: 9/20/21 (v. 1.2)
CSTritt 107:61b9c99a4e27 9 */
Jonathan Austin 0:2757d7abb7d9 10 #include "mbed.h"
CSTritt 108:eee3167b25b4 11
CSTritt 108:eee3167b25b4 12 BusOut barGraph(D2, D3, D4, D5, D6, D7, D8, D9); // Create BusOut object.
CSTritt 108:eee3167b25b4 13
CSTritt 108:eee3167b25b4 14 int main() {
CSTritt 108:eee3167b25b4 15 // Test the wiring.
CSTritt 108:eee3167b25b4 16 barGraph = 0; // All bars off (base 10).
CSTritt 108:eee3167b25b4 17 ThisThread::sleep_for(400); // For 0.4 seconds.
CSTritt 108:eee3167b25b4 18 barGraph = 0b01010101; // Odd bars on (binary).
CSTritt 108:eee3167b25b4 19 ThisThread::sleep_for(400); // Test even bars for 0.4 seconds.
CSTritt 108:eee3167b25b4 20 barGraph = 0b10101010; // Even bars on (binary).
CSTritt 108:eee3167b25b4 21 ThisThread::sleep_for(400); // Test even bars for 0.4 seconds.
CSTritt 108:eee3167b25b4 22 barGraph = 0xFF; // All bars on. Hex.
CSTritt 108:eee3167b25b4 23 ThisThread::sleep_for(400); // For 0.4 seconds.
CSTritt 108:eee3167b25b4 24 // Enter main loop.
CSTritt 108:eee3167b25b4 25 while(true) {
CSTritt 108:eee3167b25b4 26 for (int i = 0; i < 256; i++) { // Add one to count.
CSTritt 108:eee3167b25b4 27 barGraph = i; // Copy the count to the bargraph.
CSTritt 108:eee3167b25b4 28 ThisThread::sleep_for(100); // Display the value for 0.1 seconds.
CSTritt 108:eee3167b25b4 29 }
CSTritt 108:eee3167b25b4 30 }
CSTritt 108:eee3167b25b4 31 }