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: mbed DebounceIn
Revision 1:dd514e5c6507, committed 2020-02-29
- Comitter:
- maazshaikh
- Date:
- Sat Feb 29 10:05:48 2020 +0000
- Parent:
- 0:ca31694551ed
- Commit message:
- lol
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Sep 20 14:03:10 2011 +0000
+++ b/main.cpp Sat Feb 29 10:05:48 2020 +0000
@@ -3,12 +3,14 @@
// must import Cookbook Debounce library into project
// URL: http://mbed.org/users/AjK/libraries/DebounceIn/lky9pc
-DigitalOut myled(LED1);
-DigitalOut myled2(LED2);
-DigitalOut myled3(LED3);
-DigitalOut myled4(LED4);
+
+DigitalOut myled3(p11);
+DigitalOut myled4(p12);
+DigitalOut myled2(p13);
DebounceIn pb(p8);
+DebounceIn pb1(p9);
+DebounceIn pb2 (p10);
// SPST Pushbutton count demo using internal PullUp function
// no external PullUp resistor needed
// Pushbutton from P8 to GND.
@@ -19,17 +21,90 @@
int count=0;
int old_pb=0;
int new_pb;
+int old_pb1=0;
+int new_pb1;
+int order =0;
+int old_pb2=0;
+int new_pb2;
+
+
// Use internal pullup for pushbutton
pb.mode(PullUp);
+ pb1.mode(PullUp);
// Delay for initial pullup to take effect
wait(.001);
- while(1) {
+ while (1){
+ myled4=1;
+ wait(0.5);
+ myled3=1;
+ wait(0.5);
+ myled2=1;
+ wait(0.5);
+ myled4=0;
+ wait(0.5);
+ myled3=0;
+ wait(0.5);
+ myled2=0;
+ wait(0.5);
+
+ while(1) {
new_pb = pb;
- if ((new_pb==0) && (old_pb==1)) count++;
- myled4 = count & 0x01;
- myled3 = (count & 0x02)>>1;
- myled2 = (count & 0x04)>>2;
- myled = (count & 0x08)>>3;
+ new_pb1 = pb1;
+ new_pb2= pb2;
+ if ((new_pb==0) && (old_pb==1)) {
+ count++;
+ if (order==1){
+ myled3=1;
+ order=2;
+ }
+ else {
+ order=0;
+ myled3=0;
+ myled4=0;
+ myled2=0;
+ wait(3);
+ break;
+ }
+ }
+ if ((new_pb1==0) && (old_pb1==1)) {
+ count++;
+ if (order==0){
+ myled4=1;
+ order=1;
+ }
+ else {
+ order=0;
+ myled3=0;
+ myled4=0;
+ wait(3);
+ break;
+ }
+ }
+ if ((new_pb2==0) && (old_pb2==1)) {
+ count++;
+ if (order==2){
+ myled2=1;
+ order=0;
+ wait(3);
+ myled3=0;
+ myled4=0;
+ myled2=0;
+ wait(3);
+ break;
+ }
+ else {
+ order=0;
+ myled3=0;
+ myled4=0;
+ myled2=0;
+ wait(3);
+ break;
+ }
+ }
+
old_pb = new_pb;
- }
+ old_pb1 = new_pb1;
+ old_pb2 = new_pb2;
+ }
+}
}
\ No newline at end of file