From 9a13b7e2fd982a7a3cd4e122208ae1f489d24a65 Mon Sep 17 00:00:00 2001 From: fabien Date: Mon, 17 Mar 2025 10:39:25 +0100 Subject: [PATCH] ajout d'un boutton poussoir --- linearclock/linearclock.ino | 18 +- linearclock/schema.svg | 414 ++++++++++++++++++++++++++++++++++++ 2 files changed, 429 insertions(+), 3 deletions(-) create mode 100644 linearclock/schema.svg diff --git a/linearclock/linearclock.ino b/linearclock/linearclock.ino index 83ca443..ac75cc8 100644 --- a/linearclock/linearclock.ino +++ b/linearclock/linearclock.ino @@ -6,6 +6,7 @@ #define NUM_LEDS 12 #define DATA_PIN 4 // Change this to match your LED strip's data pin +#define BUTTON_PIN 2 // Change this to match your LED strip's data pin #define BRIGHTNESS 25 CRGB leds[NUM_LEDS]; @@ -17,17 +18,28 @@ int second=0; void setup() { FastLED.addLeds(leds, NUM_LEDS); FastLED.setBrightness(BRIGHTNESS); - + + Serial.begin(115200); + pinMode(BUTTON_PIN, INPUT); } void loop() { - + + int buttonState = digitalRead(BUTTON_PIN); 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)); + if(buttonState == LOW ) { + + leds[dot].setRGB( 255*(ledhour==dot) , + 255*(ledsec==dot)+ 64 * ( (ledsec-1) ==dot ) + 16 *((ledsec-2)==dot), + 255*(ledmin==dot)); + + } else { + leds[dot].setRGB(0,0,0); + } } diff --git a/linearclock/schema.svg b/linearclock/schema.svg new file mode 100644 index 0000000..87a2243 --- /dev/null +++ b/linearclock/schema.svg @@ -0,0 +1,414 @@ + + + + + + + + + + + + + + + + + + + Esp32 + + 4 + + GND + + 5V + + WS212 + + GND + + 5V + + + + + + + + 220 R + + + 2 + + GND + + 3V + + + + + + + 10K R + + + + + External 5V source + external5V power source + +