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.
Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by
main.cpp@7:6b50af097b44, 2016-01-06 (annotated)
- Committer:
- IOP
- Date:
- Wed Jan 06 07:27:52 2016 +0000
- Revision:
- 7:6b50af097b44
- Parent:
- 6:885e2cb16d7d
- Child:
- 8:bc6291805741
add integer value ain_val
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joon874 | 3:abab0082e271 | 1 | /* Analog Input Example Program */ |
sam_grove | 0:101a12a915c6 | 2 | |
sam_grove | 0:101a12a915c6 | 3 | #include "mbed.h" |
sam_grove | 0:101a12a915c6 | 4 | |
sam_grove | 0:101a12a915c6 | 5 | // Initialize a pins to perform analog input and digital output fucntions |
joon874 | 3:abab0082e271 | 6 | AnalogIn ain(A0); |
IOP | 6:885e2cb16d7d | 7 | DigitalOut myled_R(LED_RED); // LED_RED on WIZwiki-W7500 |
sam_grove | 0:101a12a915c6 | 8 | |
sam_grove | 0:101a12a915c6 | 9 | int main(void) |
IOP | 6:885e2cb16d7d | 10 | { |
IOP | 7:6b50af097b44 | 11 | int ain_val = 0; |
IOP | 5:97fa889845b0 | 12 | |
IOP | 7:6b50af097b44 | 13 | while (1) { |
IOP | 7:6b50af097b44 | 14 | |
IOP | 7:6b50af097b44 | 15 | ain_val = ain.read()*1000; |
IOP | 7:6b50af097b44 | 16 | |
IOP | 7:6b50af097b44 | 17 | // compare with specific value |
IOP | 7:6b50af097b44 | 18 | if(ain_val > 500) myled_R = 1; // Red LED OFF |
IOP | 7:6b50af097b44 | 19 | else myled_R = 0; // Red LED ON |
sam_grove | 0:101a12a915c6 | 20 | |
IOP | 5:97fa889845b0 | 21 | // output the voltage and analog values |
IOP | 6:885e2cb16d7d | 22 | printf("======================\r\n"); |
IOP | 5:97fa889845b0 | 23 | printf("voltage value : %3.3f\r\n", ain.read()*3.3f); |
joon874 | 2:5f564266c94f | 24 | printf("analog value : %3.3f\r\n", ain.read()); |
IOP | 7:6b50af097b44 | 25 | printf("analog value x1000 : %d\r\n",ain_val); |
joon874 | 2:5f564266c94f | 26 | wait(1.0); |
sam_grove | 0:101a12a915c6 | 27 | } |
sam_grove | 0:101a12a915c6 | 28 | } |
joon874 | 3:abab0082e271 | 29 | |
joon874 | 3:abab0082e271 | 30 | |
joon874 | 3:abab0082e271 | 31 | |
joon874 | 3:abab0082e271 | 32 | |
joon874 | 3:abab0082e271 | 33 | |
joon874 | 3:abab0082e271 | 34 | |
joon874 | 3:abab0082e271 | 35 | |
joon874 | 3:abab0082e271 | 36 | |
joon874 | 3:abab0082e271 | 37 |