10/7/2023 0 Comments Arduino switch button![]() Well i guess i should explain what my project does first. If( (newHallState != hallState) & (newHallState = LOW) ) It's all sequential and where you put things is all about the order you want them to happen. If you want that calculation to happen right after you read the button, then you put that line after the code that reads the button. If you want that calculation to happen right before the servo starts moving, then you put that line right before the line that starts the servo moving. So if you want that calculation to happen right before you call delay then you put that line right before the line that calls delay. First this thing happens then that thing happens then the next thing. Code works from top to bottom just how you write it. You would put that line in the place in the code where you want to calculate a new delay time. Maybe if you showed the rest of the code and explain what you mean by "doesn't work" we could help you sort it out. If it doesn't work maybe it has something to do with the rest of the code you didn't show us. What examples could i read in order to familiarize myself with this? If that is beyond you, then you need to go back and work through a few tutorials and examples and try to familiarize yourself with the language. I mean write some code that reads a button press and changes the value of delayTime variable, or possibly reads a pot and adjusts it or whatever you want to do to change the value in that variable. If( (newTiltState != TILTState) & (newTiltState = LOW)) If( (newHallState != hallState) & (newHallState = LOW)) Here instead of digitalWrite to turn led on what would i use to change a variable? the modulo function gives you the remainder of checking the modulo of the button push counter. turns on the LED every four button pushes by save the current state as the last state, if the current state is LOW then the button Serial.print("number of button pushes: ") if the current state is HIGH then the button if the state has changed, increment the counter compare the buttonState to its previous state Int TILTState = 1 // state of tilt switchĬonst int buttonPin = 3 //Define pin Button Int hallState = 1 // state of hall effectĬonst int TILT = 2 //define pin tilt switch #define TX_PIN 0 //pin where your transmitter is connectedĬonst int hallPin = 4 // define pin hall effect
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |