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.
Diff: main.cpp
- Revision:
- 2:e2441887b6d5
- Parent:
- 1:2b60776a9c3d
diff -r 2b60776a9c3d -r e2441887b6d5 main.cpp
--- a/main.cpp Wed Oct 13 14:26:21 2021 +0000
+++ b/main.cpp Wed Oct 20 15:33:27 2021 +0000
@@ -73,7 +73,7 @@
}
}*/
-DigitalIn mybutton(D7);
+/*DigitalIn mybutton(D7);
DigitalOut myled(LED1);
int main() {
@@ -90,4 +90,76 @@
wait(0.2); // 200 ms
}
}
+}*/
+
+DigitalOut led(LED1);
+DigitalIn mybutton1(A4);
+DigitalIn mybutton2(A5);
+DigitalIn mybutton3(D2);
+DigitalIn mybutton4(D7);
+DigitalOut rele(D3);
+
+int main()
+{
+ int a=0;
+ mybutton1.mode(PullNone);
+ mybutton2.mode(PullNone);
+ mybutton3.mode(PullNone);
+ mybutton4.mode(PullNone);
+
+ while(1) {
+ led = 1;
+ rele = 0;
+ if (mybutton1.read()==0){
+ if (a==0){
+ printf("Button1 state is: %d\n\r", mybutton1.read());
+ a=a+1;
+ wait(0.2);
+ }
+ }
+ if (mybutton2.read()==0){
+ if (a==1){
+ printf("Button2 state is: %d\n\r", mybutton2.read());
+ a++;
+ wait(0.2);
+ }
+ else{
+ a=0;
+ wait(0.2);
+ }
+ }
+ if (mybutton3.read()==0){
+ if (a==2){
+ printf("Button3 state is: %d\n\r", mybutton3.read());
+ a++;
+ wait(0.2);
+ }
+ else{
+ a=0;
+ wait(0.2);
+ }
+ }
+ if (mybutton4.read()==0){
+ if (a==3){
+ printf("Button4 state is: %d\n\r", mybutton4.read());
+ a++;
+ wait(0.2);
+ }
+ else{
+ a=0;
+ wait(0.2);
+ }
+ }
+ if (a==4) {
+ rele=!rele;
+ for (int i=0;i<10;i++){
+ led = !led;
+ wait(1);
+ }
+ rele=!rele;
+ a=0;
+ }
+ printf("The code is entered on: %d\n\r", a);
+ wait(0.2);
+ }
}
\ No newline at end of file