Control Different LEDs with a Joystick and Arduino
Welcome to Part 2 of my Arduino Joystick series! In this tutorial, I'll show you how to wire an analog joystick to an Arduino Uno and write a sketch to control LEDs based on joystick movements. You'll learn how to use the ADC (Analog-to-Digital Converter) values from the joystick to dynamically adjust the brightness of LEDs.
Whether you're interested in lighting effects or interactive projects, understanding joystick input for LED control is essential. Join me as we explore practical applications and expand your Arduino skills. Stay tuned for more advanced joystick techniques in upcoming videos!
PART 1: How to Use a Joystick with Arduino - Reading ADC Values: • How to Use a Joystick ...
PART 2: You're watching it!
PART 3: Control 2 Servos with a Joystick and Arduino (COMING SOON)
PART 4: Control DC Motors with a Joystick and Arduino (COMING SOON)
🛠🎨 JOIN Engineering Artists: LIVE WORKSHOPS & COMMUNITY BUILDS ▶︎ racheldebarros...
🛒 BUILD YOUR OWN Arduino Joystick Project:
Arduino Uno: amzn.to/4cJrYZu
KY-023 Joystick Module: amzn.to/3W9pDSa
LEDs: amzn.to/3zFmW28
220-330 Ohm Resistors: amzn.to/463yDvF
Jumper Wires: amzn.to/3zw9bTg
🎬 VIDEO CHAPTERS: How to Control LEDs with a Joystick and Arduino
0:00 Welcome
0:26 How to Wire a Joystick to Arduino
1:26 How to Wire LEDs to Arduino
2:57 Arduino Code: Control LED Brightness with Joystick Movements
15:01 Testing the Arduino Sketch with the Joystick
16:09 Arduino Code: map() Function Adjustments
18:27 Testing the map() Function Adjustments
18:59 Arduino Code: Defining a Joystick Idle Deadspot
21:06 Testing the final Arduino Sketch
21:38 Wrap Up: Controlling Components with a Joystick
21:43 Join my Community for Live Events & Code!
💬 Have any questions or want to share your own experiences, tips and advice about using joysticks for controlling LEDs with Arduino? Drop a comment below - I love hearing from you!
🔔 If you find this video helpful, please hit that like button 👍 and consider subscribing to my channel for more Arduino/props/robot tutorials, tips, and tricks. Your support helps me create more content like this!
Some links included here are to affiliate sites. If you purchase something through them, I may earn a small commission - which costs you nothing! I am very grateful for your support when you use my links to make a purchase.
#arduino #arduinoproject #arduinotutorial #joystick #joystickmodule #arduinocode #leds #arduinoleds
Пікірлер: 48
I'm loving your tutorials. I've been coding since the 80s (starting as an IBM systems programmer) but am a total Arduino noob. Your tutorials have been really helpful in getting up to speed. A fun enhancement would be to add a separate calibrate button. When pushed with the joystick centered, it would read the neutral X and Y values, shove them into variables, add a "fudge factor" and then use those rather than hard coding. You know what they say, "Software is never finished; at some point, it's just abandoned." lol
@RachelDeBarrosLive
Ай бұрын
That's a great idea! I should do a follow-up video to try it out! 👍
Hi Rachel, nice to see you.. hope all is good
@RachelDeBarrosLive
Ай бұрын
👍 all is great! Working on finishing up some of my projects.
Wires, lights, and knobs... oh my! this was 😞as much fun as movie night! 🎦🍿
@RachelDeBarrosLive
Ай бұрын
😆 I'm glad we figured out the dead zone during the last Office Hours live chat! It works great!
Nice vídeo and a nice way to introduce Hysteresis in a pratical way.
I know how this is going to sound, but, it is what it is. I love what youre doing. Im a polymath artist/engineer. And as such, I know what its like having projects all over the place that I am working on. I just subscribed, so im not sure full extent of your skills. With that being said, I could only imagine what you would do with a 3D printer and you were able to print your own parts. So, if you were to get 1, Id be able to help you. How? Well, Im a Maya expert and I am capable of printing anything with no limitations with 100% accuracy. So, basically, theres nothing you could think of, that I wouldnt be able to figure out how to print. Im going to be making a series of tutorials that incorporate everything (check my page) from game dev, 3D art, Geometry, 3D printing, engineering etc. Youre already helping me by doing what your doing. So, I figure if there was anything I could do to help you, I would, especially if it meant seeing what you would do with something 3d printed. For example, Im going to start working on a RC Dirt buggie, that transforms into a drone and flys. LOL. And Im going to document it from start to finish. Anytime I get to something that i feel you can explain better, which would be most things when it comes to electric, Im going to direct them to your page. Sorry for the long comment but if you actually check my page youll see im legit. Also, Theres something I havent figured out, maybe it would be a dope video for you to do. I know how to code it in Unreal, but, how would you go about zeroing out numbers to work from a scale of 0-1. For Example, In UE I would code it like this, if defualt value for X is 489, -489 and set X. X now has a value of of zero, then set max to 1000 and divide to give me 0-1. And do the same but for negative in the other direction, so the controls should technically be for accuracy 0 at defualt, -X = -1 and X =1. So .5 would be halfway moving the stick to either side. I can do this in UE but if I could it in the Arduino it would be better for me. I guess I should I mention, the RC Buggie that transforms into a drone, is going to have a VR component so itll be like youre really small driving in VR like a video game, but instead of a video game environment, itll be a real environment.. Thanks, if you took the time to read, and I apologize again for the long comment. Cheers from NYC.
Fun to see that you were able to adjust the negative action from canceling out the antiative reaction?
Thank You for the tutorial videos. Your just too cool!
@RachelDeBarrosLive
20 күн бұрын
My pleasure 😄
Very Clever, thanks
Allways nice videos, i'll try this one also,keep them coming!
Great teaching skills. Thanks.
@RachelDeBarrosLive
Ай бұрын
You are welcome!
Fun vid. ty
Another banger
Nice explanation too, thank you
youre wonderful
Wow i was just planning this on my puppet alien animatronic, you ready my mind, dont do that, my wife says its chaotic, 9 projects going at the same time, big huge projects. Love the channel playing in background when in workshop, like Adam Savage your voice is good for concentration.
@RachelDeBarrosLive
Ай бұрын
A puppet alien animatronic? That sounds awesome!
@lohikarhu734
Ай бұрын
If you want to control multiple LEDs with a lot of flexibility, and very low software overhead, lp55231 has 3 onboard LED control "engines", for 9 LEDs, which can be programmed with complex sequences, and free-run, with no further MCU overhead, or small I2C instructions that change parameters of the program execution... There is some Arduino support, and TI has a PC-based software development package... There's even a "trigger" input/output pin, to allow "chaining" multiple LP55231's.
It is caused by button bounce, so putting in a delay between the movement of the Y and X about 400 to 600 milliseconds, and a delay at the end of the loop to control the overall loop sequence again 1 second should be adequate.
Great stuff Rachel.
@RachelDeBarrosLive
Ай бұрын
👍 thanks! Let me know if there's any topics you'd like to see.
@voltampscircuits
Ай бұрын
@@RachelDeBarrosLive the topics you're covering are fine. I'm looking forward to seeing the next video about controlling a servo with the joystick.
You should be able to simplify the code and make it work more consistently by writing it like this. if (buttonState == Low){ digitalWrite(upLed, HIGH); digitalWrite(downLed, HIGH); digitalWrite(leftLed, HIGH); digitalWrite(rightLed, HIGH); }else{ analogWrite(upLed,upBrightness); analogWrite(downLed,downBrightness); analogWrite(leftLed,leftBrightness); analogWrite(rightLed,rightBrightness); } The dead-bands in the map statements should be sufficient to set the values to zero near center.
great video i have some idea to finaly use my joystick for a projet (gonna use it with yx5300 mp3 player, up/down to change folder, and left/right for playing previous/next song, and button trigger for payse/play) thx
@RachelDeBarrosLive
Ай бұрын
That's a great project idea!
Will it be possible for you to make a video on PH calibration on Arduino with detail. It will help me on my project.
How about setting all brightness variables to 0 at the beginning of each loop, then read the pins using min() and max() functions, and map the values to the respective brightness. Finally write to all leds. This would eliminate all IF statements.
@RachelDeBarrosLive
Ай бұрын
Great idea! I'll have to do a follow-up video trying this out and other good ideas people have had in the comments.
This code didn't work for me...I didn't had hairs before...and guess what?? They didn't grow after the code worked just fine!! 🤣😂🤣 Amazing tutorial!! Thank you!! 🥰
@RachelDeBarrosLive
Ай бұрын
🤣 👍 You brightened my day!
Hey Rachel been awhile, I have been playing with a CNC using Cad and writing with GCode but is itself a c++ sketch file same for Arduino ? anyway good to see you love the bangs nice look take care. 😀
@RachelDeBarrosLive
Ай бұрын
Hi Jim! Arduino is indeed based on C/C++
So analog pins are acting like some kind of potentiometers and Digital like on and off switchs am i wrong?
@RachelDeBarrosLive
Ай бұрын
You're right! The X and Y axes on the joystick each have a potentiometer. You can see them if you pop off the knob. The button works like an on/off switch.
18:52 the programmer's credo
@RachelDeBarrosLive
Ай бұрын
Yaaas! 🤣 For every 1 problem I fix, I create another 2!
good . but if you used led bar it was more attractive 💯
@RachelDeBarrosLive
Ай бұрын
Oooo.... that's a great idea! I'll have to do a follow-up video!
@naeemhaq3504
Ай бұрын
@@RachelDeBarrosLive 👌
@naeemhaq3504
Ай бұрын
@@RachelDeBarrosLive many more ideas I have
@naeemhaq3504
Ай бұрын
I am Professor of Electronics. Working on STEM EDUCATION. Want to share ideas if you are interested
There is a logical error in the code. When checking for x and y values being in the "zero zone", those should be checked independently. Otherwise one could have a situation with x being in the "zero zone" while y is not (or y but not x), causing the lights to stay on.
@hargray2
Ай бұрын
Yeah. Should be two different lines. Too many && on one line.
@RachelDeBarrosLive
Ай бұрын
Great suggestions! I'll have to do a follow-up video with many of the tweaks and improvements in these comments!