JOe Chacon / Mbed 2 deprecated JChac-342-4_2

Dependencies:   SLCD mbed

main.cpp

Committer:
ceojoe
Date:
2015-09-20
Revision:
0:5d6f30101feb

File content as of revision 0:5d6f30101feb:

#include "mbed.h"
#include "SLCD.h"

#define DATATIME 250 // 250 milliseconds
#define LASTDGDIV 10
#define PROGNAME "JChac_341_4_2_Analog Rand v1\n\r"

AnalogIn analogRand(PTB0);
DigitalOut Rled(LED_RED);
Serial pc(USBTX, USBRX);

SLCD slcd; // New instance of LCD

 
void LCDMess(unsigned int lMess){
        slcd.Home();
        slcd.clear();
        slcd.printf("%d", lMess);
}

int main()
{
    float analogValue;
    unsigned int analogBits;
    unsigned int lastDigit;
    pc.printf(PROGNAME);
    while (true) {
     analogValue = analogRand.read();
     analogBits = analogRand.read_u16();
     lastDigit = analogBits % LASTDGDIV;
     Rled = !Rled; // toggle red
     LCDMess(lastDigit);
     pc.printf("%0.5f, %d, %1d\n\r", analogValue, analogBits, lastDigit); 
     wait_ms(DATATIME);
    }
}