PortIn Hello World

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // Switch on an LED if any of mbed pins 21-26 is high
00002  
00003 #include "mbed.h"
00004  
00005 PortIn     p(Port2, 0x0000003F);   // p21-p26
00006 DigitalOut ind(LED4);
00007  
00008 int main() {
00009     while(1) {
00010         int pins = p.read();
00011         if(pins) {
00012             ind = 1;
00013         } else {
00014             ind = 0;
00015         }
00016     }
00017 }