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
Diff: main.cpp
- Revision:
- 0:c8d5f36a69d4
diff -r 000000000000 -r c8d5f36a69d4 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Sep 20 15:22:12 2018 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+
+DigitalOut led[5]= {p26,p27,p28,p29,p30};
+DigitalIn sw1(p20);
+DigitalIn sw2(p19);
+int SW1,SW2,i,p;
+
+int main()
+{
+ while(1) {//while to keep loop going//
+ SW1= sw1.read();//read in switches//
+ SW2=sw2.read();
+ if ((SW1==1) && (SW2==1)) {//if switch one and two are on//
+ p=2;
+ for(i=0;i<5;i++){//to turn on only led3 on and the rest off//
+ if(i==p){
+ led[i]=1;
+ }//end if//
+ else{
+ led[i]=0;
+ }//end else
+ } //end for//
+ }//end if//
+ else if (SW1==1) { //if only switch one is on//
+ if(p<4){//to prevent any led greater than 5 to be used//
+ led[p]=0;
+ p++;
+ led[p]=1;
+ wait(0.5);
+ }//end if//
+ }//end else if//
+ else if (SW2==1) {//if only switch two is on//
+ if(p>0){//to ensure no negative numbers are present//
+ led[p]=0;
+ p--;
+ led[p]=1;
+ wait(0.5);
+ }//end if//
+ }//end else if//
+ }//end while
+}//end main
+
+
+
+
+
+
+
+
+
+