Read an analog pin using the MultiTech Dragonfly.
Dependencies: mbed
Fork of Dragonfly_AnalogIn_Example by
main.cpp@1:ceddded7137c, 2015-10-02 (annotated)
- Committer:
- mfiore
- Date:
- Fri Oct 02 16:46:53 2015 +0000
- Revision:
- 1:ceddded7137c
- Parent:
- 0:436a6a6b80a1
update for mDot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfiore | 1:ceddded7137c | 1 | /** mDot AnalogIn Example Program |
mfiore | 0:436a6a6b80a1 | 2 | * |
mfiore | 0:436a6a6b80a1 | 3 | * This program demonstrates how to read an anglog pin using the |
mfiore | 1:ceddded7137c | 4 | * MultiTech mDot and MultiTech UDK2 hardware. The only |
mfiore | 0:436a6a6b80a1 | 5 | * additional hardware required is an analog voltage source like |
mfiore | 0:436a6a6b80a1 | 6 | * a potentiometer. |
mfiore | 0:436a6a6b80a1 | 7 | * |
mfiore | 0:436a6a6b80a1 | 8 | * |
mfiore | 1:ceddded7137c | 9 | * This program reads the analog input connected to pin PB_1 (UDK2 |
mfiore | 1:ceddded7137c | 10 | * pin A0) and prints the result. |
mfiore | 0:436a6a6b80a1 | 11 | */ |
mfiore | 0:436a6a6b80a1 | 12 | |
mfiore | 0:436a6a6b80a1 | 13 | #include "mbed.h" |
mfiore | 0:436a6a6b80a1 | 14 | |
mfiore | 0:436a6a6b80a1 | 15 | int main() { |
mfiore | 1:ceddded7137c | 16 | AnalogIn in(PB_1); |
mfiore | 0:436a6a6b80a1 | 17 | |
mfiore | 0:436a6a6b80a1 | 18 | while (true) { |
mfiore | 0:436a6a6b80a1 | 19 | printf("analog value: 0x%04X\r\n", in.read_u16()); |
mfiore | 0:436a6a6b80a1 | 20 | wait_ms(500); |
mfiore | 0:436a6a6b80a1 | 21 | } |
mfiore | 0:436a6a6b80a1 | 22 | } |