From 92794ce0fde88c34fd92f271d8815f8b2a666079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Mon, 3 Apr 2017 13:30:02 +0200 Subject: [PATCH] Create worm.ino --- School/vg2/borg/demos/worm.ino | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 School/vg2/borg/demos/worm.ino diff --git a/School/vg2/borg/demos/worm.ino b/School/vg2/borg/demos/worm.ino new file mode 100644 index 0000000..5cd118c --- /dev/null +++ b/School/vg2/borg/demos/worm.ino @@ -0,0 +1,40 @@ +// A single pxiel moves in a random direction over and over again +#include +#include + +#define NUM_LEDS 54 +#define DATA_PIN 7 + +#define WORM_COLOR (CRGB) 0x0000FF + +int select; +LEDSelect head; + +CRGB leds[NUM_LEDS]; + +void setup() { + FastLED.addLeds(leds, NUM_LEDS); + initMap(); + randomSeed(analogRead(0)); + setColor({0, 255, 255}, (CRGB) 0x0, leds); + + do { + select = random(0, NUM_LEDS); + } + while (select == 5 || !(select % (9 + 5))); + + leds[select] = WORM_COLOR; + FastLED.show(); + delay(500); + + encodeLED(select, &head); + +} + +void loop() { + FastLED.clear(); + getNeighborLED(&head,random(0,4),&head); + setColor(head, WORM_COLOR, leds); + FastLED.show(); + delay(1000); +}