![]() ![]() As it stands right now all I have left are pins 0 and 1. I should mentioned that I have tried the buttons on different Digital pins with no difference. The one constant is that whichever button is represented by the outermost level of code is the one that functions (it will allow me to switch between those four modes), though the other button remains lifeless. I have tried the code as shown, I have put one section or the other in nested loops within loop(), I have tried to break them into functions and call them from loop(), I have tried an assortment of different things. just that the user will push one or the other at random throughout the operation of the program, so the two monitoring sections have to be independent of one another and constantly running. I am not saying that the user will push both buttons at the SAME TIME. I need to monitor both buttons all the time. I have stripped out the majority of the control code for you to simply focus on the logic of what I am trying to do. OK - here is basically what I was trying. If I go through all the modes, each case switch (button press) WILL update the sensor reading once, but it does not continuously update multiple times per second as it does when NOT in a switch statement just in the regular loop(). I have put the code in the case statements, I have put the code within loops within the case statements, I have done everything I can think of. The second problem is that once in the switch statement, the sensor does not update within the code.the user wouldn't necessarily press the first button and then the second, nor would they have to press the second button first then the first.) The user would press either button at random (i.e. How can I have the program monitor both buttons and react accordingly depending on which is pressed? I would need one button to control one aspect of the program, and the second to update another aspect of the program. I have one button connected to digital 0, and one connected to digital 1. I suppose I could use just ONE button to switch between all the various modes, but I don't want to have to press a button 20 times to get to the correct mode. I have tried to put both switch statements into various loops, but I just can't figure out how to get this to work. If I use two Switch statements, the program only sees the first switch statement and seems to ignore the second. However, I can not figure out how to monitor two separate buttons. I can obviously get one button to operate properly and toggle through the various modes in EITHER the display modes OR the alert modes. Alert mode simply turns on various outputs (display only, LED, buzzer, LED & Buzzer). Display mode reads a temperature sensor and each mode converts the value into various formats (F, C, F&C, min/max). ![]() I have TWO momentary push buttons which I need to use to control two different aspects of a program - display mode and alert mode.Slowly getting back into thanks to Arduino. I used to be very good at C a long time ago, but haven't used it in about a decade. This may be a silly question, so sorry in advance. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |