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
Revision 1:1fb5ff2554ca, committed 2018-09-26
- Comitter:
- m210198
- Date:
- Wed Sep 26 18:45:40 2018 +0000
- Parent:
- 0:db1b39babf83
- Commit message:
- Part A
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Sep 20 19:20:10 2018 +0000 +++ b/main.cpp Wed Sep 26 18:45:40 2018 +0000 @@ -1,33 +1,48 @@ #include "mbed.h" +#include <stdio.h> +//Program A LAB2 +//This program turns the led lights of a protobaord on and off in a specific sequence +//Written by 3/C ASHLEY and 3/C LOZA with help from 3/C Hendricks +//Modified: +// 9/25/18 3/C ASHLEY debugged + + + int main() { -DigitalOut tony[5]={p26,p27,p28,p29,p30}; - tony[p26]=0; - tony[p27]=0; - tony[p28]=1; - tony[p29]=0; - tony[p30]=0; - int x; - Digital sw1( +DigitalOut tony[5]={p26,p27,p28,p29,p30};// pins for all the leds on the Protobaord + tony[0]=0;//These next lines of code start the intial conditions of all leds off but the third + tony[1]=0; + tony[2]=1; + tony[3]=0; + tony[4]=0; + int x, Sw1, Sw2; // varibales to store switches + Digital sw1(p19); // location of switches on mbed pin + Digital sw2(p20);// location of switches on mbed pin + while(1) { - if(sw1== 1 && sw2==1){ - tony[x]=0; - x=2; - tony[x]=1; + Sw1=sw1;//designates varibales as the switches + Sw2=sw2;//designates varibales as the switches + if((Sw1== 1)&& (Sw2==1)){// if switch 1 and switch 2 are on then light the led three + tony[0]=0; + tony[1]=0; + tony[2]=1; + tony[3]=0; + tony[4]=0; } - else if (sw1==1){ - tony[x]=0; - if(x=4); + else if ((Sw1==1) && (Sw2==0)){//if switch 1 is on and switch 2 are off then + tony[x]=0;//then cylce through leds turning the lights on in squential order by turning the previous led off and the next led on in the other way + if(x<4); x++;} tony[x]=1; - wait(0.5); + wait(0.5);// wait before exacting the next set of code } - else if (sw2==1){ - tony[x]=0; - if(x=0); + else if ((Sw1==0) && (Sw2==1)){//if switch 1 is off and switch 2 are on then + tony[x]=0;//then cylce through leds turning the lights on in squential order by turning the previous led off and the next led on + if(x>0); x--;} tony[x]=1; - wait(0.5); + wait(0.5);// wait before exacting the next set of code } } }