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
Diff: main.cpp
- Revision:
- 0:aada457e96b6
- Child:
- 1:dac1b3639634
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Feb 20 01:43:54 2015 +0000
@@ -0,0 +1,77 @@
+//(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); //PTD1
+DigitalOut myRedLED(REDLED, LEDOFF); //PTB18
+
+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

