Hi Rongyos, I will be happy to share the project. We can create an entry for it on the Downloads page the same way we have with other user designs. In addition to your Arduino code, if you have a schematic, board files (Eagle or Gerber or whatever), and list of parts (what we call a "BOM" for "bill of materials") we can post all that as well. Even only understanding the subtitles, your video was very clear to me!
I wrote a short description but if I have said anything incorrect or if you would like to modify it, just let me know!
Hi Rongyos, I'm not sure I know which "Back to Default" signal you are referring to - is this in the Standalone IR code? Where is the code waiting for anything to go back to HIGH? Are you using the negative signal from the Taigen connected to Pin D4 on the Arduino as the trigger to fire the cannon?
case BUTTON_WAIT: if (InputButton.wasReleased()) { // A single press (short) of the button will fire the cannon FireCannon(); } else if (InputButton.pressedFor(2000)) { // User has held down the input button for two seconds (long press) // Wait for them to release the button before proceeding do { delay(10); InputButton.read(); } while (!InputButton.wasReleased()); ButtonState = BUTTON_WAIT; // Now you could take some other action here to occur on long button press // bla bla
/*----------------------------------------------------------------------* * isPressed() and isReleased() check the button state when it was last * * read, and return false (0) or true (!=0) accordingly. * * These functions do not cause the button to be read. * *----------------------------------------------------------------------*/uint8_t OP_Button::isPressed(void){ return _state == 0 ? 0 : 1;}uint8_t OP_Button::isReleased(void){ return _state == 0 ? 1 : 0;}/*----------------------------------------------------------------------* * wasPressed() and wasReleased() check the button state to see if it * * changed between the last two reads and return false (0) or * * true (!=0) accordingly. * * These functions do not cause the button to be read. * *----------------------------------------------------------------------*/uint8_t OP_Button::wasPressed(void){ return _state && _changed;}uint8_t OP_Button::wasReleased(void){ return !_state && _changed;}
// PROCESS BUTTON PRESS // -------------------------------------------------------------------------------------------------- switch (ButtonState) { // The BUTTON_WAIT state watches for a press of the button (or GND signal) on D4. case BUTTON_WAIT: if (InputButton.isPressed()) { FireCannon(); } }
I think I might see another problem where the reload delay is not being taken into account properly, but let's test this change first, and if that solves your problem, I will update the code and issue a release with this fix and a fix for the reload delay.