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:859e0fd616ee, committed 2015-01-26
- Comitter:
- mbedschool
- Date:
- Mon Jan 26 09:10:53 2015 +0000
- Commit message:
- ch5_mbed_dust_sensor
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 Jan 26 09:10:53 2015 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+InterruptIn probe(p19);
+DigitalOut led(LED1);
+
+Timer timer;
+Ticker ticker;
+
+uint32_t low_time = 0;
+
+void down();
+void up();
+
+void tick()
+{
+ pc.printf("%d us, %f %%\r\n", low_time, low_time / (30.0 * 1000000));
+ low_time = 0;
+}
+
+void down()
+{
+ probe.rise(&up);
+ led = 0;
+ timer.start();
+}
+
+void up()
+{
+ led = 1;
+ timer.stop();
+ probe.fall(&down);
+
+ low_time += timer.read_us();
+ timer.reset();
+}
+
+int main()
+{
+ pc.baud(115200);
+ pc.printf("Dust Sensor test\r\n");
+ probe.fall(&down);
+ ticker.attach(tick, 30);
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jan 26 09:10:53 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file