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.
Dependencies: DebounceIn mbed
main.cpp
- Committer:
- vjain419
- Date:
- 2015-11-16
- Revision:
- 0:74d1c03b0439
- Child:
- 1:0a9d678c6d6c
File content as of revision 0:74d1c03b0439:
#include "mbed.h"
#include "DebounceIn.h"
DigitalOut l1(LED1);
DigitalOut l2(LED2);
DigitalOut l3(LED3);
DigitalOut l4(LED4);
DebounceIn pb(p8);
// SPST Pushbutton demo using internal PullUp function
// no external PullUp resistor needed
// Pushbutton from P8 to GND.
int main() {
int count=0;
int old_pb=1;
int new_pb;
pb.mode(PullUp);
wait(0.01);
while(1) {
new_pb = pb;
if((new_pb == 0) & (old_pb ==1))
count++;
l4 = count & 0x01;
l3 = (count & 0x02) >> 1;
l2 = (count & 0x04) >> 2;
l1 = (count & 0x08) >> 3;
old_pb = new_pb;
}
}