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.
Revision 1:ffa16c2a347f, committed 2016-11-09
- Comitter:
- suupen
- Date:
- Wed Nov 09 04:15:29 2016 +0000
- Parent:
- 0:a7d68fd605f6
- Commit message:
- This library is switch(push button) noise cancel and on/off edge recognition.
Changed in this revision
| DigitalSw.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DigitalSw.lib Sun Oct 23 09:47:14 2016 +0000 +++ b/DigitalSw.lib Wed Nov 09 04:15:29 2016 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/suupen/code/DigitalSw/#cd8bb4f0b08d +https://developer.mbed.org/users/suupen/code/DigitalSw/#9198c5c0afcb
--- a/main.cpp Sun Oct 23 09:47:14 2016 +0000
+++ b/main.cpp Wed Nov 09 04:15:29 2016 +0000
@@ -1,23 +1,34 @@
#include "mbed.h"
#include "DigitalSw.h"
-DigitalSw sw(p21);
+//DigitalSw sw1( p21, 1);
+//DigitalSw sw2( p22, 1);
+
+DigitalSw sw[] = {
+ DigitalSw(p21),
+ DigitalSw(p22),
+ DigitalSw(p23)
+ };
DigitalOut level(LED4);
-DigitalOut onEdgeToggle(LED1);
-DigitalOut offEdgeToggle(LED2);
+DigitalOut onEdgeToggle1(LED1);
+DigitalOut onEdgeToggle2(LED2);
+DigitalOut onEdgeToggle3(LED3);
int main() {
while(1) {
- level = sw.getLevel();
+ level = sw[0].getLevel();
- if(sw.getOnEdge() == 1){
- onEdgeToggle = !onEdgeToggle;
+ if(sw[0].getOnEdge() == 1){
+ onEdgeToggle1 = !onEdgeToggle1;
}
- if(sw.getOffEdge() == 1){
- offEdgeToggle = !offEdgeToggle;
+ if(sw[1].getOnEdge() == 1){
+ onEdgeToggle2 = !onEdgeToggle2;
+ }
+ if(sw[2].getOnEdge() == 1){
+ onEdgeToggle3 = !onEdgeToggle3;
}
}