PortIn Hello World
Dependencies: mbed
Fork of PortIn_HelloWorld by
main.cpp@0:92064442fd12, 2013-02-12 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Feb 12 12:08:15 2013 +0000
- Revision:
- 0:92064442fd12
PortIn HelloWorld
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:92064442fd12 | 1 | // Switch on an LED if any of mbed pins 21-26 is high |
mbed_official | 0:92064442fd12 | 2 | |
mbed_official | 0:92064442fd12 | 3 | #include "mbed.h" |
mbed_official | 0:92064442fd12 | 4 | |
mbed_official | 0:92064442fd12 | 5 | PortIn p(Port2, 0x0000003F); // p21-p26 |
mbed_official | 0:92064442fd12 | 6 | DigitalOut ind(LED4); |
mbed_official | 0:92064442fd12 | 7 | |
mbed_official | 0:92064442fd12 | 8 | int main() { |
mbed_official | 0:92064442fd12 | 9 | while(1) { |
mbed_official | 0:92064442fd12 | 10 | int pins = p.read(); |
mbed_official | 0:92064442fd12 | 11 | if(pins) { |
mbed_official | 0:92064442fd12 | 12 | ind = 1; |
mbed_official | 0:92064442fd12 | 13 | } else { |
mbed_official | 0:92064442fd12 | 14 | ind = 0; |
mbed_official | 0:92064442fd12 | 15 | } |
mbed_official | 0:92064442fd12 | 16 | } |
mbed_official | 0:92064442fd12 | 17 | } |