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.
Revision 0:8179372e7aaa, committed 2009-12-21
- Comitter:
- hollie
- Date:
- Mon Dec 21 15:38:02 2009 +0000
- Commit message:
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Dec 21 15:38:02 2009 +0000
@@ -0,0 +1,51 @@
+// EdgeCounter on mbed
+//
+// Counts falling edges on p5.
+// Used as test setup for interfacing a hall sensor to our water/gas sensor.
+//
+// Whenever the hall sensor triggers, edgecount is incremented and the
+// current value is transmitted to the serial port.
+//
+// Any character sent to the serial port returns the current count value
+//
+// Written by Lieven Hollevoet
+
+#include "mbed.h"
+
+// Create objects
+Serial pc(USBTX, USBRX);
+DigitalOut status(LED4);
+DigitalOut count(LED2);
+InterruptIn sensor(p5);
+
+int edgecount;
+
+void ISR_serial(void) {
+
+ char tmp = pc.getc();
+ status = 1;
+
+ pc.printf("Current edge count is %i\r\n", edgecount);
+ status = 0;
+}
+
+void falling_edge(void){
+ edgecount++;
+ count = 1;
+ pc.printf("Falling edge, count is %i!\r\n", edgecount);
+ count = 0;
+}
+
+int main() {
+
+ count = 0;
+ edgecount = 0;
+
+ pc.printf("Edgecounter started");
+
+ // Attach interrupt handlers
+ pc.attach(&ISR_serial);
+ sensor.fall(&falling_edge);
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Dec 21 15:38:02 2009 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0