It's a bad design practice to put a switch across a capacitor without a small discharge resistor in the path. That's because i = c * dv/dt. Hence, the current is infinite when the switch is shorted and the switch life will be shortened as a result. A small value (able to take the power and not drop too much voltage in the case where the switch is enabled) resistor should do the job.
Shouldn't you have another 10k resistor in series with the switch? As drawn, when you push the switch the capacitor leads are connected with 0 ohms, so your RC time constant calculation doesn't apply here. Your debounce appeared to work for the few times you tried it only because the time spent bouncing slowed down the cap discharge enough. You should actually add a 10k between the switch and one of the cap leads. Or am I seeing it wrong? Thanks for your help.
"we could use an else if, same some processing time" no, you MUST use an else if, otherwise it will change the value to red, then check if its red, then change it to yellow, then check if its yellow, then change it to green. so the function will always end with the value being green. you disapoint me sir.
I'm also curious if you would be able to treat the characters you're reading in from the SD card as strings, then append or concatenate them into one big string in a variable, then convert that to an integer instead of the power of tens style method you used?
could this have been done without interrupts using loops? like a while loop to loop while the button is in the open state? just curious, I'm sure it's much less efficient doing it that way (if it's actually possible)
Hey, my interrupt will trigger on the rising edge (as programmed) which is what I wanted. However, as soon as I inserted some codes to enable my motors in the main loop, the interrupt signal from my photo interrupter tends to interrupt far more times than it should. It is supposed to interrupt when the infra-red is being blocked by an object once at 0-1 rising edge, but it is triggering like 100+ times when i run a paper to block the infra-red on the photo interrupter.
Could you use something like an Op-amp instead of a Smitt trigger? Of course that wouldn't invert the signal.. but would convert the signal to a square wave right?
Your hardware debounce is nice but isn't it possible to call detachInterrupt() as first thing in your interrupt function and then, after a delay, attach it again to the pin?
@theblackfluid That sounds reasonable, but it goes against common practice for an interrupt anyways. All other system functions are suspended within an interrupt, so even if you could do a delay, you shouldn't. You should enter the interrupt, do something simple (like flip a global variable) then get out as fast as possible.
@sciguy14 Oh yes, you're right. I even remember that delay() and delayMicroseconds() don't work inside an ISR. But you can do those things: detachInterrupt() (maybe in c to be faster), flip your variable and then store the time inside another global variable. So later on in the loop() you could check how much time has passed and attach the interrupt again to the pin. Not the best but in lack of place (schmitt trigger and cap are'nt that small) it's okay for a manually pushed buttton i think.
@sciguy14 I have a problem. Basically i noticed that there was a slight change in the code in that you have included the two serial lines. I went back to tutorial 2 and to my surprise the line: Serial.println(digitalRead(switchPin));
caused the bouncing of the signal to stop. I would like to understand why this is the case. Also, erroneous reading are still occurring now that I deleted that line from the code..
@CIPHERJAY Well it didn't cause it to stop - it's just that's only printing it out in relatively long intervals, so you never see the value change in the terminal window.
Will the Arduino still set the interrupt flag if the interrupt is tripped while detached? Or do I have to clear the flag before reattaching to prevent the ISR from running right away? Thanks!
I'm having trouble using interrupts with while-loops. My ISR stops interrupting when my while loop is working; it seems like the ISR is waiting for the while-loop to finish. Do you have any advice on how to fix this problem?
It's refreshing to see a coder who spots and fixes his typos as he goes. Shows you know what you're doing. Too many online coding tutorials seem to just be copying from a printed script, then they run it, and spend the next 15 minutes trying to figure out why it didn't work.
Brilliant tutorials, thoroughly enjoyed every one. Informative and interesting! Will definitely be missing these every Monday! Good luck with your studies!
Absolutely amazing, I watched through all of your tutorials and was impressed by the clarity of the explanations on how the circuits worked. That is very hard to find in tutorials and you did a stunning job. It was perfect gateway for a programmer like me who wants to get into hardware.
@raghunitin They are a little different, since the trigger has an integrated feedback loop. Think of them like a not gate with a positive feedback loop.
They have an inherent hysteresis so that the output is effectively damped for a short period.Check out the symbol for a schmitt trigger for a visual clue.
Great videos, thank you for making them all I've learnt a lot.
MintSauce 2 weeks ago
It's a bad design practice to put a switch across a capacitor without a small discharge resistor in the path. That's because i = c * dv/dt. Hence, the current is infinite when the switch is shorted and the switch life will be shortened as a result. A small value (able to take the power and not drop too much voltage in the case where the switch is enabled) resistor should do the job.
SixWildKids 2 weeks ago
what camera do you use?
MostElectronics 2 weeks ago in playlist Tutorial Series for Arduino
Can you elaborate on why "else if" is more efficient than starting a new "if" block?
enticed2zeitgeist 3 weeks ago in playlist More videos from sciguy14
What program did you used for the schematics?
Pagweb 2 months ago
@Pagweb He mentioned in another video he was using EagleCad, which is free and open source.
BusinessHugs 2 months ago
Shouldn't you have another 10k resistor in series with the switch? As drawn, when you push the switch the capacitor leads are connected with 0 ohms, so your RC time constant calculation doesn't apply here. Your debounce appeared to work for the few times you tried it only because the time spent bouncing slowed down the cap discharge enough. You should actually add a 10k between the switch and one of the cap leads. Or am I seeing it wrong? Thanks for your help.
nobody1828 3 months ago
"we could use an else if, same some processing time" no, you MUST use an else if, otherwise it will change the value to red, then check if its red, then change it to yellow, then check if its yellow, then change it to green. so the function will always end with the value being green. you disapoint me sir.
123456789robbie 3 months ago
@123456789robbie It looks like his program ran as expected.
enticed2zeitgeist 3 weeks ago in playlist More videos from sciguy14
Y U NO CREATE LED ARRAY?!
123456789robbie 3 months ago
I'm also curious if you would be able to treat the characters you're reading in from the SD card as strings, then append or concatenate them into one big string in a variable, then convert that to an integer instead of the power of tens style method you used?
skyykloudz 4 months ago
could this have been done without interrupts using loops? like a while loop to loop while the button is in the open state? just curious, I'm sure it's much less efficient doing it that way (if it's actually possible)
skyykloudz 4 months ago
what software are you using for the circuit diagrams?
thanks
gricka31 5 months ago in playlist Tutorial Series for Arduino
Hey, my interrupt will trigger on the rising edge (as programmed) which is what I wanted. However, as soon as I inserted some codes to enable my motors in the main loop, the interrupt signal from my photo interrupter tends to interrupt far more times than it should. It is supposed to interrupt when the infra-red is being blocked by an object once at 0-1 rising edge, but it is triggering like 100+ times when i run a paper to block the infra-red on the photo interrupter.
xxang1 6 months ago
Could you use something like an Op-amp instead of a Smitt trigger? Of course that wouldn't invert the signal.. but would convert the signal to a square wave right?
mahela1993 6 months ago
you have a dog barking at about 10 minutes.
Your tutorial series have really helped me do a high school project.
weirdphysics 6 months ago in playlist Arduino Uno tutorials
Your hardware debounce is nice but isn't it possible to call detachInterrupt() as first thing in your interrupt function and then, after a delay, attach it again to the pin?
theblackfluid 6 months ago
@theblackfluid That sounds reasonable, but it goes against common practice for an interrupt anyways. All other system functions are suspended within an interrupt, so even if you could do a delay, you shouldn't. You should enter the interrupt, do something simple (like flip a global variable) then get out as fast as possible.
sciguy14 6 months ago
@sciguy14 Oh yes, you're right. I even remember that delay() and delayMicroseconds() don't work inside an ISR. But you can do those things: detachInterrupt() (maybe in c to be faster), flip your variable and then store the time inside another global variable. So later on in the loop() you could check how much time has passed and attach the interrupt again to the pin. Not the best but in lack of place (schmitt trigger and cap are'nt that small) it's okay for a manually pushed buttton i think.
theblackfluid 6 months ago
Is pin 1 on the trigger connected to the yellow wire and pin 2 connected to PWM 2?
CIPHERJAY 7 months ago
@CIPHERJAY correct.
sciguy14 7 months ago
@sciguy14 I have a problem. Basically i noticed that there was a slight change in the code in that you have included the two serial lines. I went back to tutorial 2 and to my surprise the line: Serial.println(digitalRead(switchPin));
caused the bouncing of the signal to stop. I would like to understand why this is the case. Also, erroneous reading are still occurring now that I deleted that line from the code..
CIPHERJAY 7 months ago
@CIPHERJAY Well it didn't cause it to stop - it's just that's only printing it out in relatively long intervals, so you never see the value change in the terminal window.
sciguy14 7 months ago
Hey, does anyone know where to get the Schmitt trigger chip from a UK based seller? Thanks!
CIPHERJAY 8 months ago
@CIPHERJAY You can make this work without the trigger. You just need to invert your logic in software.
sciguy14 7 months ago
Will the Arduino still set the interrupt flag if the interrupt is tripped while detached? Or do I have to clear the flag before reattaching to prevent the ISR from running right away? Thanks!
17171717 8 months ago
can you post your code?
redhotdaddy 9 months ago
@redhotdaddy Link in description. It's on my site.
sciguy14 8 months ago
Hey Jeremy,
I'm having trouble using interrupts with while-loops. My ISR stops interrupting when my while loop is working; it seems like the ISR is waiting for the while-loop to finish. Do you have any advice on how to fix this problem?
sh3r1ly 10 months ago
@sh3r1ly That shouldn't happen unless you're disabling interrupts in your while loop. What are you doing in the loop?
sciguy14 9 months ago
Hi Jeremey,
Really great tuto serie. I had a good time watching them while waiting to my Arduino Mega board.
Can't wait to get my board and then it would be time to go over your tuto's again and put in practice what I learned.
Hope to see next tuto soon. Keep on your nice job!
n2048 10 months ago
This is great. Thanks a lot!
victorgunnar21 10 months ago
please make more soooooon!!
robertcarter1987 10 months ago
awesome! this is why i subscribe to you, keep up the good work, im learning so much
glennlopez 11 months ago
@glennlopez :D thanks!
sciguy14 11 months ago
Hi Jeremey,
Really great tuto serie. I had a good time watching them while waiting to my Arduino Mega board.
Can't wait to get my board and then it would be time to go over your tuto's again and put in practice what I learned.
Hope to see next tuto soon. Keep on your nice job!
n2048 10 months ago
Great tutorial. Thanks.
zooto68 11 months ago
Great video, learned a lot, What's the name of the program you used to draw the schematics?
MitchDC2 11 months ago
@MitchDC2 eaglecad
sciguy14 11 months ago
It's refreshing to see a coder who spots and fixes his typos as he goes. Shows you know what you're doing. Too many online coding tutorials seem to just be copying from a printed script, then they run it, and spend the next 15 minutes trying to figure out why it didn't work.
kaouthiavideo 11 months ago
Great tutorials, thank you.
Looking forward to see more.
All the best in your studies.
azmahmoud89 11 months ago
@WakkoXtreme Yes, sparkfun makes an SPI matrix that is well suited for that.
sciguy14 11 months ago
Brilliant tutorials, thoroughly enjoyed every one. Informative and interesting! Will definitely be missing these every Monday! Good luck with your studies!
bmonty65 11 months ago
Absolutely amazing, I watched through all of your tutorials and was impressed by the clarity of the explanations on how the circuits worked. That is very hard to find in tutorials and you did a stunning job. It was perfect gateway for a programmer like me who wants to get into hardware.
iluvme162 11 months ago
@iluvme162 So glad you liked them!
sciguy14 11 months ago
This has been flagged as spam show
awesome tutorial,i will be looking forward for your next tutorial on arduino.Thanks it has been a great help.
forgetmichel62 11 months ago
awesome tutorial,i will be looking forward for your next tutorial on arduino.Thanks it has been a great help.
forgetmichel62 11 months ago
Yep, Really good video's guy, I have found them very very useful to me, just like to say thanks,
Thom in Scotland.
fuelban 11 months ago
I know you said this was your last but please make more in the future. these have been a tremendous help. thanks!
jakebrickhouse 11 months ago
@jakebrickhouse Not last, forever! I'm hoping there will be more soon.
sciguy14 11 months ago
i suggest you start a series like onsholders blogs latest dogbot project. Take a big project and divide in to episode.
karandex 11 months ago
And this would have been great if it had been a RGB LED!!!!!!
raghunitin 11 months ago
Inverting schmitt trigger is just a NOT gate right?
raghunitin 11 months ago
@raghunitin They are a little different, since the trigger has an integrated feedback loop. Think of them like a not gate with a positive feedback loop.
sciguy14 11 months ago
@sciguy14
@raghuntin
They have an inherent hysteresis so that the output is effectively damped for a short period.Check out the symbol for a schmitt trigger for a visual clue.
@sciguy14
Great vids. Thankyou
KeeFCrook 11 months ago
love the series, come back soon and make more!
swiz747 11 months ago
aw i just started watch the series
Shockszzbyyous 11 months ago
ok buddy thanks again!
MrAAK95 11 months ago
when will you return? great series till now though. these episodes have been really very informative. Thankyou!
MrAAK95 11 months ago 5
@MrAAK95 I'm *hoping* to film more episodes over spring break - so hopefully I'll return soon.
sciguy14 11 months ago 6