From eae5ab055ee7b0a8e817e793752186a1089f972d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Mon, 3 Apr 2017 13:27:03 +0200 Subject: [PATCH] Create random.ino --- School/vg2/borg/demos/random.ino | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 School/vg2/borg/demos/random.ino diff --git a/School/vg2/borg/demos/random.ino b/School/vg2/borg/demos/random.ino new file mode 100644 index 0000000..cd471ee --- /dev/null +++ b/School/vg2/borg/demos/random.ino @@ -0,0 +1,30 @@ +#include +#include + +#define NUM_LEDS 45 +#define DATA_PIN 7 + +CRGB leds[NUM_LEDS]; + +void setup() { + FastLED.addLeds(leds, NUM_LEDS); + + randomSeed(analogRead(0)); +} + +void loop() { + FastLED.clear(); + FastLED.show(); + + for (int i = 0; i < NUM_LEDS; i++) { + int select; + do { + select = random(0, NUM_LEDS); + } + while (leds[select] != (CRGB) 0x0); + leds[select] = (CRGB) random(1, 0x1000000); + FastLED.show(); + delay(250); + } + delay(1000); +}