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@1:b0fc2c9a5d06, 2016-11-09 (annotated)
- Committer:
- Snay22
- Date:
- Wed Nov 09 20:14:31 2016 +0000
- Revision:
- 1:b0fc2c9a5d06
- Parent:
- 0:44fc57e03a56
- Child:
- 4:41bbbaecd322
Init
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Snay22 | 0:44fc57e03a56 | 1 | #include "mbed.h" |
Snay22 | 0:44fc57e03a56 | 2 | |
Snay22 | 0:44fc57e03a56 | 3 | AnalogIn ain(A0); |
Snay22 | 0:44fc57e03a56 | 4 | Serial pc(USBTX, USBRX); |
Snay22 | 0:44fc57e03a56 | 5 | DigitalOut dout(LED1); |
Snay22 | 0:44fc57e03a56 | 6 | |
Snay22 | 0:44fc57e03a56 | 7 | int main() { |
Snay22 | 0:44fc57e03a56 | 8 | pc.baud(9600); |
Snay22 | 1:b0fc2c9a5d06 | 9 | pc.printf("Getting values\r\n"); |
Snay22 | 0:44fc57e03a56 | 10 | while(1) |
Snay22 | 0:44fc57e03a56 | 11 | { |
Snay22 | 0:44fc57e03a56 | 12 | if(ain > 0.3f) { |
Snay22 | 0:44fc57e03a56 | 13 | dout = 1; |
Snay22 | 0:44fc57e03a56 | 14 | } else { |
Snay22 | 0:44fc57e03a56 | 15 | dout = 0; |
Snay22 | 0:44fc57e03a56 | 16 | } |
Snay22 | 0:44fc57e03a56 | 17 | wait(0.1); |
Snay22 | 1:b0fc2c9a5d06 | 18 | pc.printf("The value is %f\r\n", ain.read()); |
Snay22 | 0:44fc57e03a56 | 19 | } |
Snay22 | 0:44fc57e03a56 | 20 | } |