👉 Don't forget to check arduino-tutorials.net for more Arduino tutorials and projects. If you have questions, don't hesitate to ask them in de comments. Remember: There are no stupid questions 😃
@basvanvliet19704 жыл бұрын
Makker, ONZE NAAM
@BasonTechNL4 жыл бұрын
@@basvanvliet1970 😎
@sontayasaengtaw49082 жыл бұрын
You can write coad convert to angle +/- ?
@naboulsikhalid77632 жыл бұрын
that explains all the things I wanted to know and settles down all the dust that cloud my understanding of rotary encoder. Great tutorial. thank you very much
@BasonTech2 жыл бұрын
Thank you! 😃
@allanminers16623 жыл бұрын
Best ever explanation of how a rotary encoder works.Two little dots fit it
@BasonTech3 жыл бұрын
Thanks! 😃
@MikeysLab4 жыл бұрын
You should handle the denouncing in hardware, not software. Adding a couple resistors, a cap and a 74hc14 will give you a nice clean signal.
@BasonTech4 жыл бұрын
Thanks for sharing! 😃
@longdongsilver47193 жыл бұрын
I suppose you are kidding...
@MikeysLab3 жыл бұрын
@@longdongsilver4719 not at all, bouncing is a hardware problem. Always solve the problem where the problem is. Pushing it off to software is just lazy engineering
@longdongsilver47193 жыл бұрын
@@MikeysLab The right solution is the simplest one. Adding some debouncing circuitry is just over-engeneering when it comes to a simple rotary encoder. Adding active or even passive components increase the risk of failure and the cost. Lazyness is not a criteria in engeneering but efficiency, production cost and MTBF are the real way to think your design.
@MikeysLab3 жыл бұрын
@@longdongsilver4719 okay let's look at the "efficency" of your idea, on one hand we save about 7 cents per encoder. On the other we have to pay an embedded software engineer to write a complicated debounce function that will not use delays or hinder main program execution in anyway, or use a multi core micro controller and dedicate a thread to the ui alone, which as a embedded software engineer is going to take about 16 hours to design implement and effectively test before it should be released in a product. Factor in I charge $200/hr for dev time and your 7 cent savings just cost you a whole hell of a lot of money. The easiest solution is not always the right solution. This is what makes people use strings over char[] in Arduino and get into trouble with memory fragmentation
@Sparklift4 жыл бұрын
Great video. Clear instructions. Please do more and more videos
@BasonTech4 жыл бұрын
Thanks, will do! 😃
@soonfamous7 ай бұрын
Great video Bas :) i bumped into your channel and I immediately got hooked on the quality of your explanation! I did follow the tutorial with ease. Unfortunately my rotary encoder is still giving me false values (even when I try to move it slowly). I am thinking to apply some filter on the raw values (avg of 3) perhaps? Any pro advice on how manufacturers usually solve problems like that?
@BasonTech7 ай бұрын
I think averaging is not the way to go tbh. I am more wondering if the rotary encoder is malfunctioning or that some wiring is causing this issue. Have you tried with another rotary encoder?
@mrcanisters2 жыл бұрын
thanks. just what was after. very well explained.
@BasonTech2 жыл бұрын
Great to hear, thanks! 😃
@stevenirish61605 жыл бұрын
Thank you!
@tonholper62822 жыл бұрын
Hi Bas, wich Rotary encoder are u using, it has a pushfunction wich i need
@BasonTech2 жыл бұрын
Hi, in the description of every video is a list with all the components. Here you find links to Dutch and international stores.
@jaimeriquelme67273 жыл бұрын
Hi Bas on tech, how did you verify this program when ' digitalPinToInterrupt' was not declare in this scope, help me please to understand. Thanks for your time.
@BasonTech3 жыл бұрын
Hi Jaime, please make sure you have no typos in the naming of digitalPinToInterrupt and see if all the { and } are opening and closing at the correct place.
@jaimeriquelme67273 жыл бұрын
@@BasonTech, I've already checked many times, but I'm not the only one with this problem, someone said reinstall the IDE program and try again but it didn't work. Any other suggestion, I'm using an old Dell laptop with Windows XP. Thanks a lot for your patience.
@BasonTech3 жыл бұрын
@@jaimeriquelme6727 Did you copy my source code from the course material to make sure there aren't any typos?
3 жыл бұрын
I´ve tested it on other pins that arent 3 and 4 and it doesnt work, why does this happend? Before you ask, I´ve changed the code so that the pins are different. If there is something misssing please let me know!
@BasonTech3 жыл бұрын
Hi Elías, very good question! In the code you see we attach an interrupt to pinB. As www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/ shows, for most Arduinos only pin 2 and 3 have external interrupts. So therefore you can only use these pins 😃
3 жыл бұрын
@@BasonTech Thank you soo much for answering this fast!! This means we could only use this method for 2 simultaneous digital encoders??
3 жыл бұрын
@@BasonTech Well I've seen that my arduino Leonardo has more than 2 pins with external interrupts. Thats means I only need one for each digital encoder? Thank you again and hope to see something from you soon!
@BasonTech3 жыл бұрын
Indeed 1 interrupt pin for 1 encoder. However there might be some PCB out there which can multiplex multiple encoders on a single pin
@longdongsilver47193 жыл бұрын
Thanks for your help. This video kept me surely from searching for the solution during hours. I was using the polling method to read my encoders and it was far from satisfying. I had lots of misreads and the reliablilty depended too much on the encoder quality. Interrupts was the way to go. BTW, your english pronunciation is perfect ;-)
@BasonTech3 жыл бұрын
Glad it helped and thanks! 😄
@_twich_80963 жыл бұрын
lets say i want to connect 2 encoder, i assume is possible to contec the pinA to arduino pin2 and 10 and the other encoder pinA to arduino pin3 and 11. i assume thinks will work the same way. of course by doublening the code, with deferent pins and names, will this work?
@BasonTech3 жыл бұрын
Correct, however it is better to not repeat code but split it up in reusable functions 😃
@ipadize2 жыл бұрын
i have first added the encoder without interrupts- which worked semi okay (its not reading fast enough), so i added the interrupt. Now when i turn the encoder my whole program will stop. I call a switch case with the interrupt and the switch case calls another switch case inside, maybe using an interrupt is forbidden with nested switch cases?
@BasonTech2 жыл бұрын
I know that the code within the interrupt needs to be as small as possible. A switch adds logic so perhaps you are right and is it not advised to do so.
@ipadize2 жыл бұрын
@@BasonTech i have changed my code to only use buttons - short press once and long press continuously change a value (i still have to add that long press tho).
@EricEllenbrook4 жыл бұрын
Theoretically could you assign a count to the encoder so when you turn to the left it decreases and to the right it increases? And could you display that value on the LCD screen?
@BasonTech4 жыл бұрын
Hi Eric, that is not only theoretically but also practically possible 😃
@EricEllenbrook4 жыл бұрын
@@BasonTech im new to arduino and this video gave me the inspiration I needed to get started! I hope to share a video with you one day :)
@BasonTech4 жыл бұрын
Hi Eric, if you're new to Arduino, I would really recommend to start with tutorial #1. You'll learn a lot of basics in the first few tutorials. Looking forward for your video! Use the hashtag #basontech 😃
@dreamseer20073 жыл бұрын
I loved your video, but when implementing the interrupt, I am now getting left on left and mostly left on right. Before implementing the interrupt each direction is mostly correct.
@BasonTech3 жыл бұрын
Hi, make sure you have wires connected correctly. Sometimes the encoder is damaged and "slips" resulting in wrong output
@dreamseer20073 жыл бұрын
@@BasonTech Thank you! I changed the encoder and the new one works perfectly. 🙂
@BasonTech3 жыл бұрын
Great! A disadvantage of rotary encoders is that they wear over time and start slipping
@AnakRantauan_NL-Industry4 жыл бұрын
If led brightness control with two leds. How to code ?
@BasonTech4 жыл бұрын
Hi Anak, I am not sure what you want to achieve. Do you want to control the led brightness? You can use PWM for that. It is explained in this tutorial kzbin.info/www/bejne/Z5fLg5ljZberr7M
@unalakdogan94163 жыл бұрын
Perfect
@BasonTech3 жыл бұрын
Thanks! 😃
@mihalceaalexandru91142 жыл бұрын
Where are interrupts used?!
@BasonTech2 жыл бұрын
at 9:32
@Leviathan07072 жыл бұрын
my encoder bounce all the time and it is driving me crazy, how do you make it not bounce
@BasonTech2 жыл бұрын
Maybe there is a malfunction in the rotary encoder? Have you tried another one?
@Leviathan07072 жыл бұрын
@@BasonTech I try all of it mate. From the rotary encoder with breakout board to the stand alone one, they all bounce the same way to me :((( it's pretty frustrating
@BasonTech2 жыл бұрын
If that is the case, it should be either your wiring, or your code. Please check the pin layout of your encoder to be absolutely sure the pins are not labeled different than mine in the video
@Leviathan07072 жыл бұрын
@@BasonTech i double check everything for an entire month, I search on youtube a found that many people have the same problem as me. But it seems like you don't encounter such problem at all
@BasonTech2 жыл бұрын
Indeed not at all, it just worked. Are you using the Arduino Uno as well?
@djproducerty886 жыл бұрын
Kan je een video maaken over RBG led
@BasonTechNL6 жыл бұрын
Bedoel je RGB led met vier pootjes of de WS2812B adresseerbare LED strips?
@djproducerty886 жыл бұрын
Met vier potjes
@BasonTechNL6 жыл бұрын
@@djproducerty88 Die werkt precies hetzelfde als een gewone LED :) Een RGB led is eigenlijk een 3 in 1 LED. Je kunt hem dus aansluiten als een gewone LED. Afhankelijk van welk pootje je kiest wordt hij rood, groen of blauw zie sites.google.com/site/ardunitydoc/_/rsrc/1453009974510/getting-started/run-examples/rgb-led/RGB_LEDCircuit%28Analog%29.png
@djproducerty886 жыл бұрын
@@BasonTechNL maar je moet tog resistors gebruiken?
@BasonTechNL6 жыл бұрын
@@djproducerty88 Klopt, dat kan op precies dezelfde manier als in het plaatje. Over elke korte pin zet je een weerstand :)
@darrenmurrey637 Жыл бұрын
that annoying that there are only two interrupts . i want to run two encoders and just realised why 1 is having difficulties
@BasonTech Жыл бұрын
I believe the Arduino Mega has more interrupts.
@shokdj1 Жыл бұрын
Cheers mate I appreciate your info I may buy a few mega’s. Turns out there’s another way I found something a library that give you interrupts on any pin. There a catch it stops interrupts on everything but it doesn’t matter on my project as you’ll only use 1 thing at a time so it’s working pretty decent now. Although I’m trying to work on an optical rotary encoder and 3d printing the rotary ir blocker there’s just not enough ticks per rotation on a general encoder for what I need it for.
@startobytes5 жыл бұрын
Can you make more videos please
@BasonTech5 жыл бұрын
I would really like to. Unfortunately I currently have quite a busy job, which makes it very hard to record new videos. When times are less rural I will certainly record new videos :)
@startobytes5 жыл бұрын
@@BasonTech than can make the videos on the weekend, Not?
@startobytes5 жыл бұрын
Can you make 1 Video per week? I Hope you can make it.
@BasonTech5 жыл бұрын
@@startobytes Unfortunately that is not going to work. Keep in mind that creating a video requires preparation, recording, editing, writing the code, artwork and updating the website. Topic getting more complicated as well, and therefore preparation will take more and more time before I can start recording :)
@startobytes5 жыл бұрын
@@BasonTech thanks,
@محمددرارني-ف7ن5 жыл бұрын
Teach us!
@BasonTech5 жыл бұрын
I will, don't worry. Unfortunately this is quite a busy time for me. I borrow the camera from a friend, so I am not always able to record new episodes. However, I have certainly plans to make new episodes this year :)