Let me start off by saying that I am a beginner. I had lots of help with this code but he isn't able to help me at the moment.
I have been working on a smoker controller for a couple years. Now that I have the smoker design complete I am back to the controller. I have been having issue with the rotary encoder restarting the arduino or just putting random characters all over the screen when being rotated. I have tried software and mechanical debouncing and nothing seems to work so I am wanting to switch to a manual set of buttons to raise and lower the temperature.
I have tried different approaches and I keep getting errors. I am hoping someone can assist me in getting this to work. Any help is much appreciated.
Attached is the last working code using the rotary encoder. It is over 9000 characters so I cant just add to post.
Robin2:
If you take ALL the Serial and LCD stuff and ALL the delay()s out of the set() function what happens?
Then post your revised code if that does not work
If you are just using an encoder turned by a person as an input device I can see no reason why it should not work with the correct code.
Post a link to the datasheet for the encoder.
...R
I removed Serial and the 2 delays. Seems to be more responsive. But after a few interrupts it fails. I have attached a video. I also attached a diagram.
If you read the encoder link you posted, you will find that they use pullup resistors on the two encoder outputs.
You don't appear to have any fitted in your firtzy, or a pullup statement in your code.
I don't know if the library turns pullups on.
Without pullups the inputs are floating when the encoder output switches are open, so the input is neither 0 or 5V.
The other thing is the capacitor and resistor in your encoder press switch.
I would assume its debounce, but your arrangement does not make sense, with the capacitor in series with the switch and arduino input.
Have you tried the suggested code that the site provides to see if you are reading the encoder correctly?
After a long night I have made good process. After removing the delays, serial communication, and the latest debounce circuit WE (with you help) have it almost working. The error is now happening only when I press the button, either to enter or exit interrupt. This causes me to think I was chasing 2 different things.
The new debounce:
As for the pull up resistors, the switch has them on the back.
The De-Bounce sequence was from a tutorial I watched.
Robin2:
You did not respond to the advice in Replies #8 and #9. It makes it much easier to help if you do.
I haven't tried the code suggested in my link, yet. As for the pullup resistors the KY040 had 10k integrated in the circuit.
Robin2:
If you have a new version of your program you need to post it.
I will when I change the encoder section.
Robin2:
I thought the problem was reading an encoder rather than debouncing a switch?
Your suggestion to remove all the serial and delays helped the rotation errors. Once I was able to get past that the rotation errors I found the momentary switch issue. The switch issue was being masked by the encoder issue. I did some late night reading and decided to try a debouncing circuit. I will post my new attempt in the next day or two. I have sons t-ball tonight so could be tomorrow. This family stuff is getting in the way of my arduino stuff.