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
main.cpp
- Committer:
- DIGL1024W15
- Date:
- 2015-02-20
- Revision:
- 1:dac1b3639634
- Parent:
- 0:aada457e96b6
File content as of revision 1:dac1b3639634:
//(c) Fanshawe College, 2015
#include "mbed.h"
#define LEDON 1
#define LEDOFF 0
#define GREENLED PTA4
#define YELLOWLED PTA12
#define REDLED PTD4
#define FLASH_STOP_LED 0
#define FLASH_GO_LED 1
#define PB_PRESSED 0
#define PB_RELEASED 1
Serial terminal(USBTX, USBRX);
DigitalOut myGreenLED(GREENLED, LEDOFF);
DigitalOut myRedLED(REDLED, LEDOFF);
DigitalIn modeSwitch(PTD5);
int main()
{
myGreenLED = LEDOFF;
myRedLED = LEDOFF;
bool buttonHasBeenReleased = true;
int mode = FLASH_STOP_LED;
terminal.printf("Machine Stopped\n\r");
while(1)
{
int switchpos = modeSwitch.read();
terminal.printf("Mode Switch: logic level %d\n\r", switchpos);
if( switchpos == PB_PRESSED && buttonHasBeenReleased == true)
{
if(mode == FLASH_STOP_LED)
{
mode = FLASH_GO_LED;
terminal.printf("Machine Started...\n\r");
}
else
{
mode = FLASH_STOP_LED;
terminal.printf("Machine Stopped... reload\n\r");
}
buttonHasBeenReleased = false;
}
else if (switchpos == PB_RELEASED)
{
buttonHasBeenReleased = true;
}
if( mode != FLASH_STOP_LED )
{
terminal.printf("Producing part\n\r");
myRedLED = LEDON;
wait(.2);
myRedLED = LEDOFF;
wait(0.2);
}
else
{
terminal.printf("Machine safely stopped\n\r");
myGreenLED = LEDON;
wait(.5);
myGreenLED = LEDOFF;
wait(0.5);
}
}//eo infinite loop
}//eo main

