SEARCH
TOOLBOX
LANGUAGES
modified on 18 September 2014 at 16:24 ••• 21,468 views

06-05 ModularCodeExample

From Manuals

(Difference between revisions)
Jump to: navigation, search
Support (Talk | contribs)
(Created page with 'This program is an example of using modular code. /* Program Example 6.5: main.cpp file for modular 7-seg keyboard controller This example program includes example code PE6…')
Newer edit →

Revision as of 15:36, 14 August 2014

This program is an example of using modular code.

/* Program Example 6.5: main.cpp file for modular 7-seg keyboard controller

This example program includes example code PE6.06, PE6.07, PE6.08, PE6.09
                                                                           */
#include "mbed.h"
#include "HostIO.h"
#include "SegDisplay.h"
char data1, data2;                    // variable declarations

int main() {                          // main program
  SegInit();                          // call init function
  HostInit();                         // call init function
  while (1) {                         // infinite loop
    data2 = GetKeyInput();            // call to get 1st key press
    Seg2  = SegConvert(data2);        // call to convert and output
    data1 = GetKeyInput();            // call to get 2nd key press
    Seg1  = SegConvert(data1);        // call to convert and output
    pc.printf("  ");                  // display spaces on host
  }
}


File:BAM210 06 05 SCH.png
Schematic for example 06-05