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
Revision 1:e1478ad47f58, committed 2015-02-08
- Comitter:
- jaredwil
- Date:
- Sun Feb 08 15:44:04 2015 +0000
- Parent:
- 0:e7ca1ba9745c
- Commit message:
- commented;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jan 29 21:09:01 2015 +0000
+++ b/main.cpp Sun Feb 08 15:44:04 2015 +0000
@@ -1,33 +1,48 @@
+//Part 3
+//This function is used to simply identify whether a specific
+//input from a button is a dot or dash based on the length of
+//time the button is pressed
+
#include "mbed.h"
+//Initialize Interrupt
InterruptIn pound(p25);
+//Initialize Digital Out
DigitalOut myled(LED1);
+//Initialize Timers
Timer t1;
Timer t2;
+//Serial Interface for Debugging
Serial pc(USBTX, USBRX);
+//Function to be called when button is pressed
void pPress () {
- t2.stop();
- if(t2.read_ms() > 400)
- pc.printf(" ");
- t1.start();
- myled = 1;
+ t2.stop(); //stop space timer
+ if(t2.read_ms() > 400)//if the length is greater than 400ms
+ pc.printf(" "); //space if added
+ t1.start(); //start dot/dash timer
+ myled = 1; //turn on led for debugging
}
+
+//Function Called when button is released
void pRelease() {
- t1.stop();
- if(t1.read_ms() > 30 && t1.read_ms() <= 200)
- pc.printf(".");
+ t1.stop(); //stop dot/dash timer
+ if(t1.read_ms() > 30 && t1.read_ms() <= 200)
+ pc.printf("."); //dot if length less than 200ms
else if (t1.read_ms() > 200)
- pc.printf("-");
+ pc.printf("-"); //dash if length greater than 200ms
myled = 0;
-
+ //reset both timers
t1.reset();
t2.reset();
+ //start space timer
t2.start();
}
+//mainfunction
int main() {
myled = 0;
+ //Initialize Interrupts for rising/falling edge
pound.rise(&pPress);
pound.fall(&pRelease);
t2.start();