![]() ![]() StartTime = millis() // Begin timing sequence Set Button to Input and Enable Built in Pull up Resistor This is my code : // Connect Button between pin and groundĬonst byte button = 2 // choose your pinĬonst int ledPin = 13 // the number of the LED pinĬonst long interval = 2000 // 1 second = 1000 millis So this is working, but only the same as before. If (buttonCount = 10) // This is what adjusts sensitivityīuttonState = true // we accept this as a good button pressīuttonState = false // we do not accept this as a good button press if we get x number of consecutive positive reads If (buttonRead = 0) // the button was pressed If (buttonState = HIGH) //= interval) // End timing sequenceīool checkButton() // Function to read button and Debounce it Is there any way I can allow, either with code or with a resistor / cap, to trigger via a switch that has a wire length of <2m? I used the Arduino button tutorial and used a 10k pull down resistor as stated. However I'm new to Arduino and not sure how to implement this. I've been reading on forums that using debounce may solve this problem. read the state of the pushbutton value: initialize the pushbutton pin as an input: Int buttonState = 0 // variable for reading the pushbutton status They're used hereĬonst int buttonPin = 2 // the number of the pushbutton pinĬonst int ledPin = 10 // the number of the LED pin ![]() The code I use at the moment that does work with short wires is: // constants won't change. What I'm trying to do is, when I press a button I would like it to output to a pin, stay on for 2 seconds, then turn off regardless whether the button is still pressed or not. ![]() If I use a shorter wire I have no problems, but as soon as they are extended, things start playing up. I'm having a bit of trouble with my Arduino when I try and use long wires to a switch. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |