SHENZHEN I/O

SHENZHEN I/O

View Stats:
Chaz Oct 19, 2016 @ 12:10am
Making a button fire a signal once per press
So I've found myself making gadgets in the sandbox, because why not? It's pretty fun!

I'm trying to make a system that uses three push button (N4PB-1000) modules as inputs - I'll spare the chunk of the programming, because there's just one part I haven't fully grasped even after reading through the manual:

What can I do to prevent the button from firing a signal multiple times when held down? I only want it to fire a signal once when pressed, and not do anything else until I let go of the button and push it again.
< >
Showing 1-5 of 5 comments
Tikigod Oct 19, 2016 @ 12:56am 
Initial thought would be to store a state value such as in a MC or RAM to act as a conditional.

So on input from button: Check conditional is false then do something, once done set conditional to true in dat/acc/whatever you fancy using as a state monitor.

Then of course when button is released (button is sending 0 again) set conditional back to false.

Edit: A bit of food for thought, the 3 button D-pad controller (N4GP-1000) is a Xbus connective device that actually has a unique value input for each button that's sent only once when the button is first pressed, and sends a negative button value when the button is released.

So if you press button 'A', it will send a value of '5' once no matter how long you hold it. When it's released is will send '-5'.
Last edited by Tikigod; Oct 19, 2016 @ 1:05am
jeff Oct 19, 2016 @ 4:48am 
tgt p0 acc + # p0 was pressed in the last time unit mov p0 acc
Chaz Oct 19, 2016 @ 9:53am 
Alright, what about if I have two buttons hooked up to the same microcontroller, that I want to do different things? Say for instance I have one button that moves a selector up, the other that moves the selector down. What I want to know is how to send a signal for each case.
Tikigod Oct 19, 2016 @ 10:47am 
Originally posted by Chaz:
Alright, what about if I have two buttons hooked up to the same microcontroller, that I want to do different things? Say for instance I have one button that moves a selector up, the other that moves the selector down. What I want to know is how to send a signal for each case.

Two different ways (edit: technically three) to approach it in terms of behaviour are pretty much covered in the previous two posts.

Now it's just a case of putting it into practise and finding the practical layout for what you want to achieve. No one can really tell you what your design is for you, in fact many take efforts to avoid doing anything that remotely resembles that.

If you're still early on and have only just unlocked the sandbox, it might be a good idea to move on to the other tasks first and unlock other components and have their uses and additional concepts introduced properly.

It may give you some inspiration for going back and approaching your own ideas.
Last edited by Tikigod; Oct 19, 2016 @ 10:54am
BtB Oct 19, 2016 @ 10:58am 
If you want an up/down controller, I suggest using an index. That way you're not playing around with two sets of conditionals just have an ADC controller for the buttons that contains your anti-bounce stuff (what you originally asked about) and outputs either +1 or -1 on an xbus. SLX the target controller, then just add the bus, using ACC as the current menu position elsewhere. Lossy in materials, but robust in code. Not bad in power, either, if you SLX all the xbus stuff you have.
< >
Showing 1-5 of 5 comments
Per page: 1530 50

Date Posted: Oct 19, 2016 @ 12:10am
Posts: 5