ajout d'un boutton poussoir

This commit is contained in:
fabien
2025-03-17 10:39:25 +01:00
parent d70160f2e8
commit 9a13b7e2fd
2 changed files with 429 additions and 3 deletions

View File

@@ -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<WS2812B, DATA_PIN, GRB>(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);
}
}

414
linearclock/schema.svg Normal file
View File

@@ -0,0 +1,414 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg5"
inkscape:version="1.2.2 (b0a8486541, 2022-12-01)"
sodipodi:docname="schema.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:document-units="mm"
showgrid="true"
showguides="false"
inkscape:zoom="0.74742565"
inkscape:cx="262.23344"
inkscape:cy="560.59088"
inkscape:window-width="1920"
inkscape:window-height="1011"
inkscape:window-x="0"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
type="xygrid"
id="grid3946" />
</sodipodi:namedview>
<defs
id="defs2">
<linearGradient
id="linearGradient6151"
inkscape:swatch="solid">
<stop
style="stop-color:#fda50a;stop-opacity:1;"
offset="0"
id="stop6149" />
</linearGradient>
<rect
x="-160"
y="160"
width="140"
height="200"
id="rect6145" />
<rect
x="580"
y="960"
width="220"
height="80"
id="rect4183" />
<rect
x="504.398"
y="202.41984"
width="133.79257"
height="129.38574"
id="rect1356" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient6151"
id="linearGradient6153" />
</defs>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="fill:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;paint-order:markers stroke fill;stroke:#000000;stroke-opacity:1"
id="rect234"
width="125.31347"
height="84.604294"
x="41.063171"
y="115.04768" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:none;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="103.7199"
y="163.89868"
id="text896"><tspan
sodipodi:role="line"
id="tspan894"
style="fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.5"
x="103.7199"
y="163.89868">Esp32</tspan></text>
<rect
style="fill:#fda50a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1052"
width="4.9559002"
height="9.9117918"
x="73.630508"
y="115.04768" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fda50a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="73.794754"
y="133.45531"
id="text1106"><tspan
sodipodi:role="line"
id="tspan1104"
style="stroke-width:0.5;fill:#fda50a;fill-opacity:1"
x="73.794754"
y="133.45531">4</tspan></text>
<rect
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1216"
width="4.9559002"
height="9.9117918"
x="56.697159"
y="115.04768" />
<text
xml:space="preserve"
style="font-size:7.05045px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.393124;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="69.357544"
y="104.82224"
id="text1220"
transform="scale(0.79772857,1.2535592)"><tspan
sodipodi:role="line"
id="tspan1218"
style="fill:#000000;fill-opacity:1;stroke-width:0.393125"
x="69.357544"
y="104.82224">GND</tspan></text>
<rect
style="fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1222"
width="4.9559002"
height="9.9117918"
x="45.584648"
y="115.04768" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="42.044724"
y="132.39699"
id="text1226"><tspan
sodipodi:role="line"
id="tspan1224"
style="stroke-width:0.5"
x="42.044724"
y="132.39699">5V</tspan></text>
<rect
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1336"
width="55.659119"
height="25.841478"
x="154.34088"
y="53.806915" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="179.82837"
y="66.727654"
id="text1340"><tspan
sodipodi:role="line"
id="tspan1338"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5"
x="179.82837"
y="66.727654">WS212</tspan></text>
<rect
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1342"
width="4.9559002"
height="9.9117918"
x="-60.393326"
y="150.36493"
transform="rotate(-90)" />
<text
xml:space="preserve"
style="font-size:7.05045px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.393124;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="-80.739014"
y="134.26212"
id="text1346"
transform="matrix(0,-0.79772857,1.2535592,0,0,0)"><tspan
sodipodi:role="line"
id="tspan1344"
style="fill:#000000;fill-opacity:1;stroke-width:0.393125"
x="-80.739014"
y="134.26212">GND</tspan></text>
<rect
style="fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1348"
width="4.9559002"
height="9.9117918"
x="-78.914185"
y="150.89409"
transform="rotate(-90)" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="-80.337433"
y="169.3017"
id="text1352"
transform="rotate(-90)"><tspan
sodipodi:role="line"
id="tspan1350"
style="stroke-width:0.5"
x="-80.337433"
y="169.3017">5V</tspan></text>
<text
xml:space="preserve"
transform="scale(0.26458333)"
id="text1354"
style="font-size:33.8917px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';white-space:pre;shape-inside:url(#rect1356);display:inline;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.88976;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill" />
<rect
style="fill:#fda50a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1360"
width="4.9559002"
height="9.9117918"
x="-69.03772"
y="149.38498"
transform="rotate(-90)" />
<path
style="fill:none;fill-opacity:1;stroke:#ff0000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
d="m 0,66.559768 c 0,0 23.717521,-7.43385 30.797378,-2.47795 7.079856,4.9559 17.265221,50.965862 17.265221,50.965862"
id="path1465" />
<path
style="fill:none;fill-opacity:1;stroke:#ff0000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
d="M 30.797378,64.081818 150.89409,76.436232"
id="path1791" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
d="m 1.5875,49.626424 c 0,0 23.717522,-7.43385 30.797379,-2.47795 7.079856,4.9559 26.790231,67.899206 26.790231,67.899206"
id="path1793"
sodipodi:nodetypes="csc" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
d="M 32.384879,47.148474 152.4816,59.502888"
id="path1795" />
<rect
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.516889;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect1877"
width="27.291851"
height="8.6181898"
x="107.97626"
y="88.721397" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="107.96782"
y="96.20549"
id="text1881"><tspan
sodipodi:role="line"
id="tspan1879"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5"
x="107.96782"
y="96.20549">220 R</tspan></text>
<path
style="fill:none;fill-opacity:1;stroke:#fdb100;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
d="m 76.108458,115.04768 c 0,0 16.983221,-22.017189 24.425512,-22.017189 7.44229,-2e-6 24.51119,2.823552 34.73414,-2e-6 10.22295,-2.823554 4.55906,-26.470721 4.55906,-26.470721 l 14.51371,0.167886"
id="path1883" />
<rect
style="fill:#fda50a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect3404"
width="4.9559002"
height="9.9117918"
x="73.630508"
y="-199.60025"
transform="scale(1,-1)" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fda50a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="73.794754"
y="188.10048"
id="text3408"><tspan
sodipodi:role="line"
id="tspan3406"
style="fill:#fda50a;fill-opacity:1;stroke-width:0.5"
x="73.794754"
y="188.10048">2</tspan></text>
<rect
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect3410"
width="4.9559002"
height="9.9117918"
x="56.697159"
y="-199.60025"
transform="scale(1,-1)" />
<text
xml:space="preserve"
style="font-size:7.05045px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.393124;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="69.357544"
y="149.25903"
id="text3414"
transform="scale(0.79772857,1.2535592)"><tspan
sodipodi:role="line"
id="tspan3412"
style="fill:#000000;fill-opacity:1;stroke-width:0.393125"
x="69.357544"
y="149.25903">GND</tspan></text>
<rect
style="fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect3416"
width="4.9559002"
height="9.9117918"
x="45.584648"
y="-199.60025"
transform="scale(1,-1)" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:#fd0a0a;fill-opacity:1;stroke:none;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="42.044724"
y="188.10048"
id="text3420"><tspan
sodipodi:role="line"
id="tspan3418"
style="stroke-width:0.5"
x="42.044724"
y="188.10048">3V</tspan></text>
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
d="m 50.540549,242.13111 h -9.727377 v 19.11561 l 26.79946,-0.35399 v -19.46961 h -8.437525"
id="path3944" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill;stroke-dasharray:none"
d="m 47.624999,232.83333 h 15.875 -10.583333 V 254 h -5.291667 15.875"
id="path3948" />
<path
style="fill:none;fill-opacity:1;stroke:#e91900;stroke-width:0.9;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
d="m 43.391667,268.28749 v -10.58334 h 5.291666"
id="path3950" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.9;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
d="M 66.145844,268.28749 V 257.70415 H 60.854178"
id="path3952" />
<path
style="fill:none;fill-opacity:1;stroke:#e91900;stroke-width:0.899999;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
d="m 47.624999,201.08333 c 0,0 -37.041666,0 -42.3333324,26.45833 C 0,254 21.166667,264.58333 21.166667,264.58333 l 22.224999,4.23334"
id="path4071"
sodipodi:nodetypes="cscc" />
<rect
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.516889;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
id="rect4073"
width="27.291851"
height="8.6181898"
x="-241.18759"
y="74.083336"
transform="rotate(-90)" />
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.499999;stroke-linecap:round;stroke-linejoin:bevel;stroke-opacity:1;paint-order:markers stroke fill"
x="-241.19603"
y="81.567322"
id="text4077"
transform="rotate(-90)"><tspan
sodipodi:role="line"
id="tspan4075"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.5"
x="-241.19603"
y="81.567322">10K R</tspan></text>
<text
xml:space="preserve"
transform="scale(0.26458333)"
id="text4181"
style="font-size:33.8917px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';white-space:pre;shape-inside:url(#rect4183);display:inline;fill:none;fill-opacity:1;stroke:#e91900;stroke-width:3.40157;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.899999;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
d="M 66.145833,269.34583 79.374999,241.82916"
id="path4187"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.899999;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
d="m 58.208333,200.025 19.579166,14.2875"
id="path4832"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-opacity:1;stroke:#fda50a;stroke-width:0.899999;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
d="m 76.199999,200.025 c 0,0 19.050001,16.93333 19.050001,32.80833 0,15.875 -2e-6,42.33334 -15.875,42.33334 -15.875,0 -13.229167,-6.87917 -13.229167,-6.87917"
id="path4834"
sodipodi:nodetypes="cssc" />
<text
xml:space="preserve"
transform="scale(0.26458333)"
id="text6143"
style="font-size:33.8917px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';white-space:pre;shape-inside:url(#rect6145);fill:none;fill-opacity:1;stroke:url(#linearGradient6153);stroke-width:3.40157;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"><tspan
x="-160"
y="390.15608"
id="tspan6236"><tspan
dx="0 20.338329 20.338329 20.338329 20.338329 20.338333 20.338326 20.338326 20.338333 20.338333 20.338333 20.338318 20.338333 20.338333 20.338318 20.338348 20.338318 20.338318"
style="stroke:#000000"
id="tspan6234">External 5V source</tspan></tspan></text>
<text
xml:space="preserve"
style="font-size:8.96718px;font-family:'Liberation Mono';-inkscape-font-specification:'Liberation Mono, Normal';fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.899999;stroke-linecap:round;stroke-linejoin:bevel;stroke-dasharray:none;stroke-opacity:1;paint-order:markers stroke fill"
x="-47.625"
y="52.916668"
id="text6157"><tspan
sodipodi:role="line"
id="tspan6155"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.9"
x="-47.625"
y="52.916668">external</tspan><tspan
sodipodi:role="line"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.9"
x="-47.625"
y="64.125641"
id="tspan6159">5V power</tspan><tspan
sodipodi:role="line"
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.9"
x="-47.625"
y="75.334618"
id="tspan6161"> source</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 20 KiB