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: NeoStrip_edit mbed
Diff: main.cpp
- Revision:
- 0:7f09c539f8c5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Apr 25 14:40:00 2014 +0000
@@ -0,0 +1,86 @@
+#include "mbed.h"
+#include "NeoStrip.h"
+
+
+#define N 59
+
+Serial pc(USBTX, USBRX); // tx, rx
+Serial device(p13,p14);
+DigitalOut myled1(LED1);
+
+NeoStrip strip(p18, N);
+
+void blinkOn();
+void blinkOff();
+
+Timer t;
+void callback(){
+ t.reset();
+ //reply ack
+ device.putc('A');
+ //clear serial buffer
+ while(device.readable()) device.getc();
+ myled1=1;
+ t.start();
+ blinkOff();
+}
+
+
+void blinkOn()
+{
+ for (int i = 0; i < N; i++)
+ {
+ if (i % 2)
+ strip.setPixel(i, 0xff, 0, 0);
+ else
+ strip.setPixel(i, 0, 0, 0);
+ }
+ wait_ms(50);
+ strip.write();
+}
+
+void blinkOff()
+{
+ for (int i = 0; i < N; i++)
+ {
+ strip.setPixel(i, 0, 0, 0);
+ }
+ wait_ms(60);
+ strip.write();
+}
+int main() {
+
+ strip.setBrightness(.1);
+
+ blinkOn();
+ wait_ms(200);
+ blinkOff();
+
+
+ //set mbed baud rate the same as BLE mini baud rate
+ device.baud(57600);
+ device.attach(&callback);
+
+ //wait until device is connected;
+ while(!device.readable()){}
+
+ while(1){
+ if(t.read_ms()>3000) {
+
+ blinkOn();
+ wait_ms(200);
+ blinkOff();
+ wait_ms(200);
+ blinkOn();
+ wait_ms(200);
+ blinkOff();
+ wait_ms(200);
+ blinkOn();
+ wait_ms(200);
+ blinkOff();
+ wait_ms(200);
+ }
+
+ }
+
+}
\ No newline at end of file