tag:blogger.com,1999:blog-4029477663972602198.post916539634746777420..comments2023-12-09T00:39:31.024-08:00Comments on Jeff's Arduino Blog: 4-Way Button: Click, Double-Click, Hold, Long Holdsalsahttp://www.blogger.com/profile/03691727863273668045noreply@blogger.comBlogger52125tag:blogger.com,1999:blog-4029477663972602198.post-65453987873788669602022-03-13T11:16:05.080-07:002022-03-13T11:16:05.080-07:00I still use this, so greatI still use this, so greatDeceptiKittyhttps://www.blogger.com/profile/04612202533653410991noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-44617735979956662732019-11-26T06:07:54.579-08:002019-11-26T06:07:54.579-08:00hi. Its is a great program and is saving me so muc...hi. Its is a great program and is saving me so much time.<br />I am trying to use analog pulse(pulse width 10ms) as a signal instead of momentary push button. i only need single and double click functionality.<br /><br />Could someone pls share the program with just those two functions, sorry i am unable to reduce the code myself as i do not know programming much !!<br />thanks in advance.<br />Anonymoushttps://www.blogger.com/profile/07330604866850267778noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-54199153666166670172016-12-10T20:25:46.853-08:002016-12-10T20:25:46.853-08:00One improvement (to an already very cool project) ...One improvement (to an already very cool project) is to add a Schmitt trigger to debounce the PB instead of the debounce delay in software. I find that the Schmitt makes the tap and double tap very crisp and sure-footed. But, that's must my personal preference for "debouncing" all switches I have problems with.<br />Thanks for the great sketch.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-20644597474649954682016-11-01T11:28:19.474-07:002016-11-01T11:28:19.474-07:00Hi Salsa,
Amazing Code. I am trying to incorporat...Hi Salsa,<br /><br />Amazing Code. I am trying to incorporate your code with a RGB LED. I have got it to work quite nicely adding some other features to it.<br /><br />At this current time, I am trying to add midi to this sketch and I am wondering is it possible to work correctly. I have got a single midi message to go across to Ableton Live and was just wondering is it possible to add multiple midi messages? Just a newb question in general.<br /><br />Thanks,<br /><br />Kind regards,<br /><br />AnthonyAnonymoushttps://www.blogger.com/profile/03737255134982801922noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-313400989689971592016-09-26T02:03:29.287-07:002016-09-26T02:03:29.287-07:00@mahesh Found your code for the four types of but...@mahesh Found your code for the four types of button presses for the Arduino.<br /><br />Any idea how many buttons I could add? I'd like to use a Mega 250 with 15-20 input buttons where each button has four functions.<br /><br />Wondering if you expanded your code for more than one button?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-29968189320312652332016-06-08T16:37:29.041-07:002016-06-08T16:37:29.041-07:00Sorry anon but the way it's currently structur...Sorry anon but the way it's currently structured, it hits the hold before the long hold. I'm sure if you made the events triggered when the button comes up (instead of while it's being held down), this would not be a big deal. You're new-- this is a perfect little project for you ;)salsahttps://www.blogger.com/profile/03691727863273668045noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-50582212922880936792016-06-03T15:33:04.572-07:002016-06-03T15:33:04.572-07:00Hi Salsa, i use your sketch and is very good.
I...Hi Salsa, i use your sketch and is very good.<br />I'm a newbie in arduino and i try without succesful to make a mod in your sketch.<br /><br />I need to separate holdevent and longholdevent:<br /><br />if i hold for >1000 but <3000 event 3<br />if i hold for >3000 only event 4<br /><br />i want to chose with time hold event 4 without make also event 3...<br /><br />Please help me....<br /><br />ByeAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-76522693133848249242016-05-27T17:49:21.516-07:002016-05-27T17:49:21.516-07:00Sounds cool! What's your question? I can't...Sounds cool! What's your question? I can't help much anyway, but I can say this:<br />Diagram your circuit,<br />Simplify your code,<br />Test one piece of code and hardware at a time.<br />Good luck and happy hacking!salsahttps://www.blogger.com/profile/03691727863273668045noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-33601255297781783112016-05-27T17:47:32.733-07:002016-05-27T17:47:32.733-07:00Sorry I can't help troubleshoot your code or c...Sorry I can't help troubleshoot your code or circuit, but maybe you can find help in the comments above or in Arduino forums. Good luck and happy hacking!salsahttps://www.blogger.com/profile/03691727863273668045noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-89394062795909771362016-05-19T18:27:36.748-07:002016-05-19T18:27:36.748-07:00hello, I want to make one button for 4 digit 7 seg...hello, I want to make one button for 4 digit 7 segment with shift register, press one for change digit ones ( count up) , press two for change digit tens (count up), press three for change digit hundreds( count up),press four for change digit thousands (count up) ,i am newbie with code arduino.tanks beforeAnonymoushttps://www.blogger.com/profile/13854579715453556553noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-66158142503356993552016-03-08T18:12:28.604-08:002016-03-08T18:12:28.604-08:00i had to make a few changes (update it?) to make t...i had to make a few changes (update it?) to make the code work. main changes:<br />1. REMOVED: #include "WProgram.h" (no longer required).<br />2. CHANGED: bpUP TO bp.<br />3. ADDED: event listeners for ALL four types of presses in the sample code.<br />4. CHANGED: time intervals for single, double, long clicks and for long press. these feel more intuitive to me.<br />5. CHANGED: event OnLongPress is raised ONLY after the button is released. it's now "on long press AND release." this feels more intuitive. code is tested and at http://pastebin.com/87cCn6h9.<br /><br />maheshhttps://www.blogger.com/profile/00592251178651344018noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-22500792802871677222016-03-01T05:45:46.716-08:002016-03-01T05:45:46.716-08:00Hello
I need help.
I'm doing a project and ne...Hello<br />I need help.<br /><br />I'm doing a project and need to have 6 buttons with these four functions , but when I try to make the addition of the 5 buttons , the relay stops working.<br />none of the buttons work<br />Am I doing something wrong ?? <br />I'm not having error message when compiling the code.<br />Anonymoushttps://www.blogger.com/profile/03766705395419650346noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-75608287122737224562015-11-16T15:07:15.810-08:002015-11-16T15:07:15.810-08:00Sorry but I can't help troubleshoot your code!...Sorry but I can't help troubleshoot your code! If you reconstruct my setup you should be able to gain some insight into the example.salsahttps://www.blogger.com/profile/03691727863273668045noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-81860716918304044732015-11-13T14:10:21.941-08:002015-11-13T14:10:21.941-08:00hello, is it possible to write the complete code?
...hello, is it possible to write the complete code?<br />i get some errors like ... was not declared in this scope<br /><br />i need this example for 2 rotary encoder. thxRalfhttps://www.blogger.com/profile/10379836636999239909noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-49315855549082015482015-05-27T05:29:34.767-07:002015-05-27T05:29:34.767-07:00hello after some trial and error , it works fine n...hello after some trial and error , it works fine now, for control of a RGB light, even on a small attiny 85chip :)<br />this little program has really made my day, good work! :)Anonymoushttps://www.blogger.com/profile/07784243986312812736noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-3584525215293052222015-04-08T03:47:25.946-07:002015-04-08T03:47:25.946-07:00Why this sketch doesn't compile today?
What h...Why this sketch doesn't compile today? <br />What has changed in newest Arduino world?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-27203235719789328652014-03-08T10:05:59.546-08:002014-03-08T10:05:59.546-08:00Ok, this is very nice, almost exactly what I need!...Ok, this is very nice, almost exactly what I need! Thanks! It's a GOOD start! But I need to make it work for multiple switches, and I'm total nube with C. I made 4 buttons be read from an array of the pins they connect to, and sent both the array index and the resulting initial pin read to your function, but I begin to realize that I probably have to make things like 'buttonLast', and maybe many more, into arrays so that the proper flags will be stored to be properly tested against. Have you or anyone else worked up multi-button code? (And what do I do to get a name showing here instead of Anonymous?)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-15673652691186612902014-02-17T20:04:58.073-08:002014-02-17T20:04:58.073-08:00Hello! I'm doing a project with the Arduino ME...Hello! I'm doing a project with the Arduino MEGA that would work great with this code but can't get it to compile. Are there libraries I need to import? How does it know those functions: checkButton(), clickEvent(), etc...?cpjhttps://www.blogger.com/profile/01791007510242178364noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-38947496162614079282014-01-22T14:59:55.001-08:002014-01-22T14:59:55.001-08:00Hi Adam, interesting problem, sounds very doable! ...Hi Adam, interesting problem, sounds very doable! Seems like you have a clear spec, so what's the problem exactly? I wonder if you're using the dreaded delay() to make the LED blink: your sketch can't detect a button state change if you're in the delay(). Keeping track of timing and looping your sketch in the KHz range makes simple work of catching any change in UI element states.salsahttps://www.blogger.com/profile/03691727863273668045noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-53036333807665412052014-01-21T18:34:28.540-08:002014-01-21T18:34:28.540-08:00So, lets step away from multiple outputs and look ...So, lets step away from multiple outputs and look at the following scenario.<br />One button, single click blinks led 3 times<br />1000 millis hold blinks led until stopped by a second switch? Can you help? Cause I'm about to snap trying to figure it out.Adamhttps://www.blogger.com/profile/03331532672725426661noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-23405145509047610952013-08-11T08:31:36.048-07:002013-08-11T08:31:36.048-07:00BTW: I think you can use a enum instead of numbers...BTW: I think you can use a enum instead of numbers, like:<br />enum KeyEvent<br />{<br /> Undefined = 0;<br /> SingleClick = 1;<br /> DoubleClick = 2;<br /> PressHold = 3;<br /> LongPressHold = 4;<br />};<br />pprobothttps://www.blogger.com/profile/08697821906427168889noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-90235983845033746142013-08-11T08:13:12.511-07:002013-08-11T08:13:12.511-07:00Some of my comments:
1, it looks like the variable...Some of my comments:<br />1, it looks like the variable: waitForUp is an unused variable<br />2, DCwaiting is actually a variable waiting for the second press down edge, right? (In double click mode)<br />3, DConUp is actually a variable waiting for the second press release edge, right? (In double click mode)<br /><br />Both of the two variable was used in checking double click mode, so I suggest change their names:<br />DCwaiting -> waitForNextDown<br />DConUp -> waitForNextUp<br /><br />Thanks.<br />pprobothttps://www.blogger.com/profile/08697821906427168889noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-20960873043327187432013-06-19T22:41:46.108-07:002013-06-19T22:41:46.108-07:00Of course! It all depends on how you read the but...Of course! It all depends on how you read the button. You could wrap it up a bunch of ways, but this is where it would help to make a library for your specific application... which is up to you ;)salsahttps://www.blogger.com/profile/03691727863273668045noreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-71866483441623867532013-06-19T22:37:09.791-07:002013-06-19T22:37:09.791-07:00Hi. Great Work.
I do have a question.
I can see ho...Hi. Great Work.<br />I do have a question.<br />I can see how your code works for a single button or even several buttons, but each connected to it's Arduino pin.<br /><br />Is there a way to make this work with 8 buttons connected to a Multiplexer (so all being read from one single AnalogRead)? That would be so great!!!<br /><br />Thanks!<br />=)Boguzhttp://4elements.netai.netnoreply@blogger.comtag:blogger.com,1999:blog-4029477663972602198.post-30786700407645740252013-06-19T09:45:35.057-07:002013-06-19T09:45:35.057-07:00Hi Jeff,
been wanting to minimize my projects by r...Hi Jeff,<br />been wanting to minimize my projects by removing my 4 microswitches to now just 1. Looking forward to implementing your code. Thanks!solaron99https://www.blogger.com/profile/08843830071585718257noreply@blogger.com