commit 515cb509f4ddb587befb14889c204f5e9bd5c639 Author: fabien Date: Sun Mar 16 18:22:10 2025 +0100 initialcommit, linearclock with smallstrip diff --git a/linearclock/linearclock.ino b/linearclock/linearclock.ino new file mode 100644 index 0000000..498b1fe --- /dev/null +++ b/linearclock/linearclock.ino @@ -0,0 +1,53 @@ +//code for a line clock + +#include + +#define NUM_LEDS 12 +#define DATA_PIN 4 // Change this to match your LED strip's data pin +#define BRIGHTNESS 60 + +CRGB leds[NUM_LEDS]; +uint8_t pos = 0; +bool toggle = false; +int hour=17; +int minute=54; +int second=0; +void setup() { + FastLED.addLeds(leds, NUM_LEDS); + FastLED.setBrightness(BRIGHTNESS); + + +} + +void loop() { + + uint8_t ledRed = (hour * NUM_LEDS) / 24; + leds[ledRed] = CRGB::Red; + + uint8_t ledBlue =(minute * NUM_LEDS) / 60; + leds[ledBlue] = CRGB::Blue; + + uint8_t ledGreen =(second * NUM_LEDS) / 60; + leds[ledGreen] = CRGB::Green; + + FastLED.show(); + + //compute next time + second++; + if( second == 60 ) { + second=0; + minute++; + } + if( minute ==60 ) { + minute=0; + hour = (hour++ ) % 24; + } + + // clear this led for the next time around the loop + leds[ledRed] = CRGB::Black; + leds[ledBlue] = CRGB::Black; + leds[ledGreen] = CRGB::Black; + delay(1000); + + +}