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:
- 29:559eb2164488
- Parent:
- 28:71bd4c83c05f
- Child:
- 30:293ee760d357
--- a/main.cpp Tue Jun 12 10:33:49 2018 +0000 +++ b/main.cpp Tue Jun 12 10:43:43 2018 +0000 @@ -26,11 +26,11 @@ ///p12 //M0 - p13 -DigitalIn d21(p13); +DigitalIn d21(p13); //Sensor right of the station //M1 - p14 -DigitalIn d22(p14); +DigitalIn d22(p14); //Sensor left of the station //M2 - p15 -DigitalIn d23(p15); +DigitalIn station(p15); //Sensor in the middle of the station //p16 //p17 @@ -294,23 +294,10 @@ } -/** -* -*Check the swithces of the box. If they have 1 value the railSiwtches flip. -* -**/ -void switching(string sw1,string sw2, string sw3, string sw4){ - string strInst = "1000" + sw1 + sw2 + sw3 + sw4; - - //unsigned int inst = stoi(strInst); - //DCC_send_command(0x06,inst,5); - -} - - /** * -* +*Checks if any of the switches of the box has been activated. +*Calls necessary function and displays LCD text. * **/ void checkSwitch(){ @@ -383,11 +370,12 @@ checkSwitch(); //Checks for switch commands everytime. - if(d21 == 1 || d22 == 1 || d23 == 1){ //If train in any of the 3 sensors of station it stops. + if(station == 1){ //If train is on the sensor at the middle of the station it stops and displays LCD text. lcd.cls(); - lcd.printf("Choo Choo station"); + lcd.printf("All aboard\n mind the gap"); DCC_send_command(DCCaddress,DCCinst_stop,400); + lcd.cls(); }else{ DCC_send_command(DCCaddress,DCCinst_forward,1); // Forward half speed train address 3