Stanley Cohen
/
analog_rand_v1
Random number generator that looks at a floating analog port.
Revision 0:4d9bc3402dd8, committed 2014-11-05
- Comitter:
- scohennm
- Date:
- Wed Nov 05 16:51:17 2014 +0000
- Commit message:
- Random number generator that looks at a floating analog port.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Nov 05 16:51:17 2014 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +#define DATATIME 250 // 250 milliseconds +#define LASTDGDIV 10 +#define PROGMANE "Analog Rand v1\n\r" + +AnalogIn analogRand(PTB0); + +DigitalOut Rled(LED_RED); +Serial pc(USBTX, USBRX); + +int main(){ + float analogValue; + unsigned int analogBits; + unsigned int lastDigit; + + while (true) { + analogValue = analogRand.read(); + analogBits = analogRand.read_u16(); + lastDigit = analogBits % LASTDGDIV; + Rled = !Rled; // toggle led + pc.printf("%0.5f, %d, %1d\n", analogValue, analogBits, lastDigit); + + wait_ms(DATATIME); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 05 16:51:17 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89 \ No newline at end of file