final

Dependencies:   Servo1 mbed

Fork of ES200_Project2_1 by Project 2

Committer:
m211656
Date:
Thu Oct 11 19:15:00 2018 +0000
Revision:
0:b6a454c0b00a
Child:
1:852f86d263c8
Project 2 trial 1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m211656 0:b6a454c0b00a 1 #include "mbed.h"
m211656 0:b6a454c0b00a 2 #include "Servo.h"
m211656 0:b6a454c0b00a 3 #include "Motor.h"
m211656 0:b6a454c0b00a 4
m211656 0:b6a454c0b00a 5 Servo myservo(p21);
m211656 0:b6a454c0b00a 6 Servo myservo2(p22);
m211656 0:b6a454c0b00a 7 Motor m(p26,p30,p29);
m211656 0:b6a454c0b00a 8 DigitalIn sw1=(p16), sw2=(p17), sw3=(p18), sw4=(p19), sw5=(p20);
m211656 0:b6a454c0b00a 9 BusOut lights(p5,p6,p7,p8,p9);
m211656 0:b6a454c0b00a 10
m211656 0:b6a454c0b00a 11
m211656 0:b6a454c0b00a 12 int main()
m211656 0:b6a454c0b00a 13 {
m211656 0:b6a454c0b00a 14 while(1)
m211656 0:b6a454c0b00a 15 {
m211656 0:b6a454c0b00a 16 if(sw1==1) {
m211656 0:b6a454c0b00a 17 lights=1;
m211656 0:b6a454c0b00a 18 //myservo motor on
m211656 0:b6a454c0b00a 19 }
m211656 0:b6a454c0b00a 20 if(sw2==1) {
m211656 0:b6a454c0b00a 21 lights=3;
m211656 0:b6a454c0b00a 22 //m turns on
m211656 0:b6a454c0b00a 23 }
m211656 0:b6a454c0b00a 24 if(sw3==1) {
m211656 0:b6a454c0b00a 25 lights=7;
m211656 0:b6a454c0b00a 26 //myservo2 on
m211656 0:b6a454c0b00a 27 }
m211656 0:b6a454c0b00a 28 if(sw4==1) {
m211656 0:b6a454c0b00a 29 lights=0xF;
m211656 0:b6a454c0b00a 30 //dc motor off
m211656 0:b6a454c0b00a 31 }
m211656 0:b6a454c0b00a 32 if(sw5==1) {
m211656 0:b6a454c0b00a 33 lights=0x1F;//wrong hex number?----need 11111 in hex
m211656 0:b6a454c0b00a 34 //servo motor off, all lights on
m211656 0:b6a454c0b00a 35 }
m211656 0:b6a454c0b00a 36 else {
m211656 0:b6a454c0b00a 37 lights=0;} //no switches on = no lights on
m211656 0:b6a454c0b00a 38
m211656 0:b6a454c0b00a 39 }
m211656 0:b6a454c0b00a 40 }