The correct way to use buttons with FastLed library, Arduino and WS2812 NEOPIXEL

  Рет қаралды 21,898

Ionut Fedaceag (TS-BB)

Ionut Fedaceag (TS-BB)

Күн бұрын

Пікірлер: 72
@Marc_Miller
@Marc_Miller 4 жыл бұрын
Hello Ionut. Great tutorial! Really good to show others how to hardware debounce and avoid using delay. One things I will point out-- the number at the end of the fadeToBlackBy line is not a time unit (not per second), but rather a fade percentage. So in your case, using 5, means fade by 5/256th, or fade by about 1.9% each time the line is run. Using 128 would be a 50% fade each time it is called.
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
Hi and thanks! :) I admit that i never read the manual for fadeToBlackBy , i presumed that is a time unit, judging by the result that is produced while changing it's value. Thanks for pointing it out! :)
@GennaroDurante-r1z
@GennaroDurante-r1z 9 ай бұрын
Your project is great. It is exactly what I want to do. The only difference is that I do not want the strip to sweep. I want to tun the whole strip red,green,blue solid respectively. switching between each color with button 1. How do you modify your code to do that?
@Electronieks
@Electronieks 3 жыл бұрын
no working link for the sketch?
@wawanirianto2130
@wawanirianto2130 3 жыл бұрын
Do you have sketch arduino nano for 2 Way ledstrip?
@مريممريومة-ف2د
@مريممريومة-ف2د 4 жыл бұрын
Hi I wander haw to use the signal from the car blinkers to the buttons
@octogames6823
@octogames6823 2 жыл бұрын
Thank you so much! I just completed this project with a 24 rgb led ring pcb. Super silly question. How do I adjust the code to keep all LED's on with no animations?
@bkmo9859
@bkmo9859 5 жыл бұрын
Can you be so kind as provide a code example for triggering the hazard light section of a sketch using the original directional controls of a motorcycle? Such as a switch with left-off-right orientation. Where as one of a right-off-left-off switch selection within 3 or 4 seconds would trigger the hazard lights. Thank you. I already have a hazard controller using attiny85 triggered by a separate switch. I want it to trigger by original switch with a right left button push.
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
I think that i understand what you need, but i need more details. Please explain with more details how the original controls work ... a clip will be nice ... and il see how i can help you.
@bkmo9859
@bkmo9859 5 жыл бұрын
@@IonutFedaceag There are no hazard lights on the motorcycle originally. just directionals. I have added hazard lights myself by adding 12v output of my own controller to the left and right positive feeds of the directional lights. I dont want to use an external switch to turn them on. I would like the arduino sketch to detect a quick right then left switching of the directional controls to start the hazard light sequence that feed flashing 12v via 2 mosfets to the directional lights. What I need is help with the code to detect the right-off-left-off switch inputs and run the loop for the hazards. The original control is a switch that latches the load of the flasher relay to the directional light. left-off-right if pushed right it stays on until you push center to release the switch, same for left. I want to go right-left-center to start the flasher code outputting to the mosfets.
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
Did you run the original signal switch thru the attiny85? Because you will need them to go thru the attiny85 to be able to detect the combination of buttons and the delay for detecting the hazard combination will also be added to both turn signals. I will think of a sollution in the comming days and i will get back to you. EDIT: Please send me a link for the original switch or at least a picture of it.
@bkmo9859
@bkmo9859 5 жыл бұрын
@@IonutFedaceag it is like the one here: kzbin.info/www/bejne/hZOXe4p8hpuUisU it is connected to the directionals only. I will add button inputs via opto-isolators to my attiny85 flasher module
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
If the switch latches in position, i think this should work... drive.google.com/file/d/1ZpcZ6TPaM5N17WZgP-P-ADVf2XVaeEqF/view?usp=sharing Am i right?
@alfredomolina2697
@alfredomolina2697 2 жыл бұрын
Hello, where did you learn to programming neopixel ws2812 LEDs, I would like learn it, it's awesome that you make
@IonutFedaceag
@IonutFedaceag Жыл бұрын
If go thru FastLed documentation fastled.io/docs/ and you know how to program in arduino, everything will be verry clear...
@JuanFunQi
@JuanFunQi 3 жыл бұрын
Thanks as always I learn a ton of something new more more more
@mannersmakethman3668
@mannersmakethman3668 2 жыл бұрын
You are my hero!!!!!!!!
@IonutFedaceag
@IonutFedaceag Жыл бұрын
🤣
@martinkuliza
@martinkuliza Жыл бұрын
And then a hero comes along With the programming strength to carry on and you cast your fears aside cause you know you can survive......... ohhhhhhhhhh so when you feel like hope is gone Come to you tube when you're strong and you'll finally see the truth THAT THE PROGRAMMING SKILLS LIES IN YOU LOL
@trueindia808
@trueindia808 4 жыл бұрын
Thanks Sir, Very nice clip & step by step detail
@stevecummins324
@stevecummins324 4 жыл бұрын
Easy software debouncing without delay loop.... In main loop update previous switch state, and read current switch state. If they aren't same that is potentially bouncing... Set a countdown timer to a high value. If countdown timer greater than 1...decrement timer by 1 Continue with rest of main loop Only consider a read button state valid if countdown value=0
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
The great thing of software is that it's always better way of doing things. Yes, that can be another way of doing it, but a timer means a float and a float takes a lot o memory... so doing it in hardware, at least for me it's cheaper (in terms of memory)...
@stevecummins324
@stevecummins324 4 жыл бұрын
@@IonutFedaceag Rather than a float you mean an unsigned long? 4bytes.
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
Yes, sorry... unsigned long... last night i had a few drinks before responding to comments! :D :) Let's say for ATtiny85, 4 bytes of memory for one variable/button is to much, from my point of view. Like i said in most of my videos and in the description of this channel, i'm not a full time programmer, so I will confuse them from time to time, so sorry for that... :) ;)
@fabiolus2007
@fabiolus2007 3 жыл бұрын
Thank You sir! Seem to work with INPUT_PULLUP eliminating resistor.
@ronitsharma7936
@ronitsharma7936 2 жыл бұрын
I was trying to implement your code into a strip of 10 less but I get an error message for "fadeToBlackBy( leds[0], COUNT, 5);" , and the error message being "cannot convert 'CRGB' to 'CRGB*' for argument '1' to 'void fadeToBlackBy(CRGB*, uint16_t, uint8_t)".
@IonutFedaceag
@IonutFedaceag 2 жыл бұрын
I think you accidentally changed something that you shouldn't have... Download the sketch again, modify only the number of leds and test again.
@steveanimatrix3887
@steveanimatrix3887 5 жыл бұрын
Good video, but it would really help if you increased your font size in your IDE when making videos so it's easier for us to read.
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
Thanks! No problem, in future videos i will make it so. ;)
@scottiusnevious5143
@scottiusnevious5143 4 жыл бұрын
So for my final project i should just solder power to the boards 5v and not from something else?
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
Everything in this example works on 5v ! But i don't think that i quit understand your question...
@samad419
@samad419 3 жыл бұрын
copied the code exact and it wont change color :( Correction! after enough understanding and watching you're video a couple times I've managed to not just get it working but control multiple LED strips with one button for each one! Thank you!
@stefint4316
@stefint4316 4 жыл бұрын
Hello, can you also provide link to the on/off, momentary and toggle switches you are using in your demonstrations? Thank you
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
Hi. Do you mean the link to the sketch used in this clip? Because the link is in the description! With pleasure! ;)
@johnvargo8050
@johnvargo8050 4 жыл бұрын
This is great information thank you. Will there be a bounce problem if powering the Arduino from the 5v power supply instead of USB?
@martinkuliza
@martinkuliza Жыл бұрын
That is completely irrelevant BOUNCE has nothing to do with power Bounce relates to the imperfection of a button's contact point and the imperfect way in which a human would press it. In a perfect world pressing a button would result in one contact of the button , Nothing more , nothing less. in the real world, a person pushes a button, they may slip, they may have water on their hands on sweat or they didn't realize they need to push harder or whatever, they have shaky hands perhaps in any case, it results in multiple contacts This has nothing to do with how you power it when using a button ASSUME THERE WILL ALWAYS BE A BOUNCE ISSUE
@jommeldockx1793
@jommeldockx1793 5 жыл бұрын
Can I know what's the best LED you've used so far?
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
Well with the buying of the ws2812b led it's a real lottery, because officially only one company is producing this type of leds and that is worldsemi ... but in real life you really don't know, because they are not marked. Until 2015 i had real problem with finding good quality leds and the majority of leds lasted about nine to twelve months, but from the mid 2015 i settled to buy the leds from only two online shops and that was a good choice, because now i don't have any problems with the leds, the only factor's that i need to get right is the cooling and a stable power supply and the leds will last. The oldest strip has almost four years and it's still working... www.iluminat-ieftin.ro/1224/Banda-LED-RGB-PIXEL-2812-60-led-m-18W ardushop.ro/ro/electronica/331-banda-leduri-rgb-neopixels-ws2812b.html?search_query=ws2812&results=4
@pablowojat4517
@pablowojat4517 3 жыл бұрын
no compila
@Outlabyrinth
@Outlabyrinth 4 жыл бұрын
thanks ! really helpful could you create a fonction when 2 button are pressed ? for exemple : if button 1 and 2 = 1 that willl run a fonction lets say changing colors could you help me to write the code ? please !!
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
With pleasure ;) Well, with the example from this clip i think you could achieve what you want... but yes, i can help you if you can't. Try it yourself and if you can't achieve it, i will make a clip on how you can use two buttons and trigger at list six functions with them.
@Outlabyrinth
@Outlabyrinth 4 жыл бұрын
@@IonutFedaceag thanks a lot you are very kind to the community !
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
​@@Outlabyrinth With pleasure... ;)
@Elysuim
@Elysuim 3 жыл бұрын
Excellent video, I'm currently searching for how to make 2 buttons produce 2 colour modes, Button 1 = Solid RED, Button 2 = fast chasing rainbow effect. Also wonder would an Opto Isolator reduce "Bounce" or are they so fast that Hardware or Software delay will still be neccessary?
@IonutFedaceag
@IonutFedaceag 3 жыл бұрын
Glad you like it. Even if you use an optocoupler, you still have to switch it on with a button, which will still produce "Bounce" and yes, the optocoupler is fast... From my experience, the condenser and resistor are the best choice when you really need to reduce "bounce", but for most cases, software debouncing is enough. 😉
@CallousCoder
@CallousCoder 3 жыл бұрын
I am not a fan of your else if statements. A good state engine can just use if statements and a state procedure, will return the next state. A while loop with an array of function pointers where the input is the state is cleanest. Although I myself only do that if we have more than 10 or so states. Because I’m also not a fan of long if blocks.
@IonutFedaceag
@IonutFedaceag Жыл бұрын
Yes i feel you, it's hard to keep track of all the states and it gets messy quickly when using a lot of if statements, but this is the method i control the best and since i don't code for living, the time limited for learning... 🙃
@xcruell
@xcruell 3 жыл бұрын
Thank you :)
@justinhawley7783
@justinhawley7783 4 жыл бұрын
Great video! It's amazing how hard it is to find in depth learning for using tactile switches with Fastled. Do you know if there is an easy way to declare the button at the beginning of an existing sketch to switch between multiple functions? For example, say I wanted to have blue change to red indefinitely, then I push the button and it changes to orange to yellow, then push it again and get a twinkle pattern, etc? I know Tweak4all has one sketch like this, but I would like to be able to make my own basic versions with a button. Sorry if this doesn't make sense, I'm not a coder but I want to learn this stuff.
@IonutFedaceag
@IonutFedaceag 4 жыл бұрын
Thanks! I didn't understand to well your question, but anything can be done... of course you will need to make some modification to your existing sketch to be able to take in account the changes made by the new code...
@nico4597
@nico4597 5 жыл бұрын
Hey, how do i pass the currentcolor value through for(int l = 0; l < NUM_LEDS_PER_STRIP; l++){ leds[l]=CRGB::currentColor; FastLED.show(); CRGB doesnt take these kinds of values Awesome tutorial btw
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
Well, if you use CRGB struct (hex color type), you need to make a list of the colors that you need and run thru them. This is a color picker www.w3schools.com/colors/colors_picker.asp and lets say that this is the hex for red color #ff0000 and you will use it like this 0xff0000 . The variable type for holding the currentColor hex value can be an unsigned long . Or you can change to CHSV struct and use it like this: for(int l = 0; l < NUM_LEDS_PER_STRIP; l++){ leds[l]=CHSV(hue,saturation,brightness); FastLED.show(); } github.com/FastLED/FastLED/wiki/FastLED-HSV-Colors Thanks.
@arifrismawanto1198
@arifrismawanto1198 5 жыл бұрын
Coding tanpa tombol ada ndak
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
???
@arifrismawanto1198
@arifrismawanto1198 5 жыл бұрын
@@IonutFedaceag sketch without buttons there or not
@IonutFedaceag
@IonutFedaceag 5 жыл бұрын
If you want the sketch without buttons, just replace this line in the sketch leds[0][pos] += CHSV( currentColor, 255, currentBrt); with leds[0][pos] += CHSV( 0, 255, 255); and ignor the rest (buttons and other code)... To set your color and intensity, just change the three values parentheses with values from 0 to 255 ... the order is (color, saturation, brightness).
@PESCADATRETA
@PESCADATRETA 3 жыл бұрын
GOOD VIDEO mate you deserve more views and subs! thank you for this awsome explanation! increase the font size for the videos ;)
@vipalsharma4120
@vipalsharma4120 Жыл бұрын
Hopeless
@IonutFedaceag
@IonutFedaceag Жыл бұрын
Why is that ?
@wawanirianto2130
@wawanirianto2130 3 жыл бұрын
Do you have sketch arduino nano for 2 Way ledstrip?
HOW TO USE WS2812B NEOPIXELS WITH FASTLED ON ARDUINO
24:32
Gadget Reboot
Рет қаралды 184 М.
How to control groups of leds in FastLed Library with Arduino and WS2812B NEOPIXEL
14:42
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Controlling WS2812B RGB LEDs
6:34
Anas Kuzechie
Рет қаралды 48 М.
DIY Smart Stairway Controller TSBB v.1.0.0 with arduino and ws2812b or ws2811
12:56
How To Control WS2812B Individually Addressable LEDs using Arduino
9:31
How To Mechatronics
Рет қаралды 1,1 МЛН
How to use Excel to Animate LEDs!  Arduino + WS2812 LEDs
17:01
Kevin Darrah
Рет қаралды 113 М.
Use Addressable LED Strip with Arduino || Essential Engineering
7:37
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН