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.
Diff: main.cpp
- Revision:
- 0:eef50401b8ae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jun 14 15:25:25 2013 +0000
@@ -0,0 +1,38 @@
+#include "mbed.h"
+Serial pc(USBTX, USBRX);
+// A class for flip()-ing a DigitalOut
+class Flipper {
+ int ii;
+public:
+ Flipper(PinName pin) : _pin(pin) {
+ _pin = 0;
+ ii = 0;
+ }
+ void flip() {
+ ii++;
+ if( ii > 4000 ) {
+ _pin = !_pin;
+ ii=0;
+ }
+ }
+private:
+
+ DigitalOut _pin;
+};
+
+DigitalOut led(LED1);
+DigitalOut led2(LED2);
+Flipper f(LED3);
+Ticker t;
+
+int main() {
+ t.attach_us(&f, &Flipper::flip, 25 ); // the address of the object, member function, and interval
+ // 25 us = 40kHz
+ //led3 = 1;
+
+ // spin in a main loop. flipper will interrupt it to call flip
+ while(1) {
+ led = !led;
+ wait(0.5);
+ }
+}
\ No newline at end of file