Tedd OKANO
/
__Serial_sample
sample code for workshop
main.cpp@0:9300e8ff8060, 2015-04-13 (annotated)
- Committer:
- okano
- Date:
- Mon Apr 13 01:53:40 2015 +0000
- Revision:
- 0:9300e8ff8060
initial version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okano | 0:9300e8ff8060 | 1 | #include "mbed.h" |
okano | 0:9300e8ff8060 | 2 | |
okano | 0:9300e8ff8060 | 3 | BusOut leds( LED4, LED3, LED2, LED1 ); |
okano | 0:9300e8ff8060 | 4 | AnalogIn ai( p20 ); |
okano | 0:9300e8ff8060 | 5 | Serial ser( USBTX, USBRX ); |
okano | 0:9300e8ff8060 | 6 | |
okano | 0:9300e8ff8060 | 7 | int main() { |
okano | 0:9300e8ff8060 | 8 | while(1) { |
okano | 0:9300e8ff8060 | 9 | leds = (int)(ai * 15.0); |
okano | 0:9300e8ff8060 | 10 | ser.printf( "voltage = %.2f\r\n", ai * 3.3 ); |
okano | 0:9300e8ff8060 | 11 | wait( 0.5 ); |
okano | 0:9300e8ff8060 | 12 | } |
okano | 0:9300e8ff8060 | 13 | } |