LED/level code

Dependencies:   mbed 16october

Committer:
jkangwi
Date:
Thu Oct 16 19:24:43 2014 +0000
Revision:
2:cd1677d8dcea
Parent:
1:9e0c8f9c58b8
dude

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alphasig 0:ac6957e368c3 1 #include "mbed.h"
jkangwi 2:cd1677d8dcea 2 #include "Motor.h"
alphasig 0:ac6957e368c3 3
alphasig 0:ac6957e368c3 4 DigitalIn sw1(p16);
alphasig 0:ac6957e368c3 5 DigitalIn sw2(p17);
alphasig 0:ac6957e368c3 6 DigitalIn sw3(p18);
alphasig 0:ac6957e368c3 7 DigitalIn sw4(p19);
alphasig 1:9e0c8f9c58b8 8 DigitalIn sw5(p20);
alphasig 0:ac6957e368c3 9
alphasig 0:ac6957e368c3 10 BusOut LED(p5,p6,p7,p8,p11);
alphasig 0:ac6957e368c3 11
alphasig 0:ac6957e368c3 12 int switch1=sw1;
alphasig 0:ac6957e368c3 13 int switch2=sw2;
alphasig 0:ac6957e368c3 14 int switch3=sw3;
alphasig 0:ac6957e368c3 15 int switch4=sw4;
alphasig 1:9e0c8f9c58b8 16 int switch5=sw5;
alphasig 0:ac6957e368c3 17
jkangwi 2:cd1677d8dcea 18 Motor poof(p26,p29,p30);
jkangwi 2:cd1677d8dcea 19
alphasig 0:ac6957e368c3 20 int main()
alphasig 0:ac6957e368c3 21 {
jkangwi 2:cd1677d8dcea 22 float motspeed=0.34;
alphasig 0:ac6957e368c3 23 LED=1;
alphasig 0:ac6957e368c3 24 while(1) {
jkangwi 2:cd1677d8dcea 25
alphasig 0:ac6957e368c3 26 while (switch1==1) {
alphasig 0:ac6957e368c3 27 LED=rand()%65;
alphasig 0:ac6957e368c3 28 wait(.5);
jkangwi 2:cd1677d8dcea 29 poof.speed(motspeed);
alphasig 0:ac6957e368c3 30 }
alphasig 0:ac6957e368c3 31 while (switch2==1) {
alphasig 0:ac6957e368c3 32 LED=rand()%65;
alphasig 0:ac6957e368c3 33 wait(.2);
jkangwi 2:cd1677d8dcea 34 poof.speed(motspeed+0.01);
alphasig 0:ac6957e368c3 35 }
alphasig 0:ac6957e368c3 36 while (switch3==1) {
alphasig 0:ac6957e368c3 37 LED=rand()%65;
alphasig 0:ac6957e368c3 38 wait(.1);
jkangwi 2:cd1677d8dcea 39 poof.speed(motspeed+0.02);
alphasig 0:ac6957e368c3 40 }
alphasig 0:ac6957e368c3 41 while (switch4==1) {
alphasig 0:ac6957e368c3 42 LED=rand()%65;
alphasig 0:ac6957e368c3 43 wait(.05);
jkangwi 2:cd1677d8dcea 44 poof.speed(motspeed+0.03);
alphasig 0:ac6957e368c3 45 }
alphasig 1:9e0c8f9c58b8 46 while (switch5==1) {
alphasig 1:9e0c8f9c58b8 47 LED=rand()%65;
jkangwi 2:cd1677d8dcea 48 wait(.03);
jkangwi 2:cd1677d8dcea 49 poof.speed(motspeed+0.1);
jkangwi 2:cd1677d8dcea 50 }
alphasig 0:ac6957e368c3 51 }
alphasig 0:ac6957e368c3 52
alphasig 0:ac6957e368c3 53
alphasig 0:ac6957e368c3 54 }