Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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); } }