David Estrada
/
HW4_2-RandomNumberGenerator
Random Number gen
Revision 0:a4501e0912a4, committed 2015-09-21
- Comitter:
- destradafilm
- Date:
- Mon Sep 21 01:06:33 2015 +0000
- Commit message:
- HW4.2
Changed in this revision
diff -r 000000000000 -r a4501e0912a4 SLCD.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SLCD.lib Mon Sep 21 01:06:33 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/SLCD/#ef2b3b7f1b01
diff -r 000000000000 -r a4501e0912a4 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Sep 21 01:06:33 2015 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "SLCD.h" + +#define PROGNAME "DEstra-HW4_2 - Random Generator" + +#define DATATIME 250 // milliseconds +#define LASTDGDIV 10 + +SLCD slcd; + +AnalogIn analogRand(PTB0); + +DigitalOut Rled(LED_RED); +Serial pc(USBTX, USBRX); + + +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 led + pc.printf("%0.5f, %d, %1d\n\r", analogValue, analogBits, lastDigit); + + // LCD // + slcd.Home(); + slcd.clear(); // wipe LCD number + slcd.printf("%1d", lastDigit); // print the lastDigit on LCD + + wait_ms(DATATIME); // 250 ms + } +} \ No newline at end of file
diff -r 000000000000 -r a4501e0912a4 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Sep 21 01:06:33 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa \ No newline at end of file