Displays 4 bit binary count on bar graph display. Demonstrates BusOut usage.

Dependencies:   mbed

Fork of Nightlight3 by Charles Tritt

main.cpp

Committer:
CSTritt
Date:
2017-11-03
Revision:
8:2be3e2339203
Parent:
7:52ed5fbb1208

File content as of revision 8:2be3e2339203:

/*
    Project: BinaryCount
    File: main.cpp
    
    Displays 4 bit binary count on bar graph display.
    
    Written by: Dr. C. S. Tritt
    Created: 9/13/17 (v. 1.1)
*/
#include "mbed.h"

BusOut barGraph(D2, D3, D4, D5);  // Create barGraph BusOut object.
DigitalOut pinD7(D7);  // Needed to force this pin off.

int main() {

    printf("Binary Count Example\n"); // ID software.
    
    pinD7 = 0; // Force pin D7 off.
    
    barGraph = 0;  // Start with all bars off.
    while(true) {
        wait(1.0);
        barGraph = barGraph + 1; // Add one to count.
        if (barGraph == 15) {
            barGraph = 0;
        }
    }
}