linear clock, mix color
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
//code for a line clock
|
||||
//code for a linear clock
|
||||
|
||||
//todo electrical scheme
|
||||
|
||||
#include <FastLED.h>
|
||||
|
||||
#define NUM_LEDS 12
|
||||
#define DATA_PIN 4 // Change this to match your LED strip's data pin
|
||||
#define BRIGHTNESS 60
|
||||
#define BRIGHTNESS 25
|
||||
|
||||
CRGB leds[NUM_LEDS];
|
||||
uint8_t pos = 0;
|
||||
@@ -21,14 +23,13 @@ void setup() {
|
||||
|
||||
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;
|
||||
uint8_t ledhour = (hour * NUM_LEDS) / 24;
|
||||
uint8_t ledmin =(minute * NUM_LEDS) / 60;
|
||||
uint8_t ledsec =(second * NUM_LEDS) / 60;
|
||||
for(uint8_t dot=0 ; dot< NUM_LEDS ; dot++) {
|
||||
leds[dot].setRGB( 255*(ledhour==dot) , 255*(ledsec==dot), 255*(ledmin==dot));
|
||||
}
|
||||
|
||||
|
||||
FastLED.show();
|
||||
|
||||
@@ -42,11 +43,6 @@ void loop() {
|
||||
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);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user