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: PololuLedStrip mbed
Fork of LedStripRainbow by
Revision 7:c5db6fcf061f, committed 2017-11-09
- Comitter:
- coloursearch
- Date:
- Thu Nov 09 17:19:45 2017 +0000
- Parent:
- 6:0882f93da02f
- Commit message:
- Initial commit
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Nov 04 18:19:38 2016 +0000
+++ b/main.cpp Thu Nov 09 17:19:45 2017 +0000
@@ -1,16 +1,17 @@
#include "mbed.h"
#include "PololuLedStrip.h"
-PololuLedStrip ledStrip(D8);
+PololuLedStrip ledStrip(p13);
-#define LED_COUNT 60
+#define LED_COUNT 20
rgb_color colors[LED_COUNT];
Timer timer;
+DigitalOut myled(LED1);
+
// Converts a color from the HSV representation to RGB.
-rgb_color hsvToRgb(float h, float s, float v)
-{
+rgb_color hsvToRgb(float h, float s, float v){
int i = floor(h * 6);
float f = h * 6 - i;
float p = v * (1 - s);
@@ -28,21 +29,25 @@
return (rgb_color){r * 255, g * 255, b * 255};
}
-int main()
-{
+int main(){
timer.start();
- while(1)
- {
- // Update the colors array.
- uint32_t time = timer.read_ms();
- for(int i = 0; i < LED_COUNT; i++)
- {
- uint8_t phase = (time >> 4) - (i << 2);
- colors[i] = hsvToRgb(phase / 256.0, 1.0, 1.0);
- }
+ myled = 1;
- // Send the colors to the LED strip.
- ledStrip.write(colors, LED_COUNT);
+ while(1) {
+
+ // Update the colors array.
+ // uint32_t time = timer.read_ms();
+
+ for(int i = 0; i < LED_COUNT; i++) {
+ //uint8_t phase = (time >> 4) - (i << 2);
+ // colors[i] = hsvToRgb(phase / 256.0, 1.0, 1.0);
+ colors[i] = (rgb_color){255, 0, 0};
+ }
+
+ // Send the colors to the LED strip.
+
+ ledStrip.write(colors, LED_COUNT);
+ wait(0.5);
}
}
