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:63a24af333a1, committed 2015-10-23
- Comitter:
- Technical_Muffin
- Date:
- Fri Oct 23 09:35:33 2015 +0000
- Parent:
- 0:f0bfe11b60fb
- Commit message:
- replace wait code with an interrupin. Works much better and shows no error in registering the button press.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f0bfe11b60fb -r 63a24af333a1 main.cpp
--- a/main.cpp Thu Oct 08 22:37:35 2015 +0000
+++ b/main.cpp Fri Oct 23 09:35:33 2015 +0000
@@ -6,16 +6,25 @@
DigitalOut led2(LED_BLUE);
MODSERIAL pc(USBTX,USBRX);
DigitalIn button1(PTC6);
+InterruptIn buttonnew(PTC6);
+void changedir(){
+ led1.write(!led1.read());
+ led2.write(!led2.read());
+ }
+
int main()
{
led1.write(1);
- led2.write(1);
+ led2.write(0);
pc.baud(115200);
+ buttonnew.mode(PullDown);
+
while(1){
pc.printf("toggle on or off %d \n ", button1.read());
- int diffa = button1.read();
+ buttonnew.fall(changedir);
+ /*int diffa = button1.read();
wait(0.2);
int diffb = button1.read();
int button_toggle = diffa-diffb;
@@ -23,9 +32,9 @@
led1.write(0);
led2.write(1);
}
- else if(button_toggle == 1 && led2.read() == 1){
+ else if(button_toggle == 1 && led1.read() == 0){
led1.write(1);
led2.write(0);
- }
- }
+ } */
+ }
}