
steve.neal
Australia
Asked
— Edited
I just want to confirm, so as to NOT release the magic smoke, I want to trigger scripts wit the press of a button or the closing of a normally open contact. I figure that I connect the Red (3.3 Volts) and White (signal) on an ADC port across the switching contacts and have a script watching the assigned ADC port for change. I also planned to connect a pull down resistor across the signal to ground to keep floating voltages in check.
Is the above correct?
Also I may need a little help with scripting, How do I wright a script to watch and wait until the contact is closed, or opened again for that matter? I need the script to pause the personality generator at least and then I can build on it from there.
Thanks for any help in advance
Steve
I'm not totally sure about the wiring, though it makes sense.
As for the code, an if/else statement will do:
Change the ADC port to the one you will be using. This should work.
Also you will need a resistor to pull down to gnd so it doesn't float. Otherwise the adc will pick up static electricity in the air.
@DJ Could you draw a little diagram of this, or take a picture? I also want to do something like this.
Or something like this maybe?
For a simple on-off button, can't you use a digital port and the GetDigital(port) command? Would be 0 when open and 1 when closed?
Alan
I've done this exact same thing with great success with the chest buttons on my B9. You're completely correct in how to wire it. Run one wire from the power pin from the ADC port of ezb to one side of the momentarily button, a second wire from the signal pin of ezb to the other side of the button. Then you can attach a 10k resistor from either the signal wire or power wire to ground (I simply attached to the ground pin of the same ADC port). The power or signal wire you attach to will determine whether it's a pull up or pull down.
Richard's script suggestion is a good way to do monitor the port to trigger a script. I may change some of my scripts to this method. However if you want the same switch to do multiple things like check and uncheck the personality generator then you need to be more creative. In this case I'll set a vearable of either on or off each time I push that button. With an if statement in a script I can check the status of that vearable and do different things like turn that control on and off. If you want, download my latest B9 project from the ez cloud and look at the first few scripts in the script manager. I can't offer the link right now. Sorry.
R1 can be 10k. If you are out of digital ports, the ADC will work. A simple script as demonstrated above will work. Loop and check for the ADC voltage to be greater than 0
Pull Down Example (recommended for this application)
Pull Up Example (opposite of pull-down)
Thanks everyone
I feel much better knowing I'm not going to blow up my EZB. I've done enough damage for this month on my B9 project,....breaking the neon while installing it,.... tired Dave knows what I'm talking about. 
Dave, I did have a quick look at your projects, but I will need to spend more time to understand them. I am away on Holidays at the moment, (Port Douglas... beautiful spot in north Queensland), so I cant do anything practical until I get home. When I did have a look though, I couldn't seem to find the "Script Manager". It occurred to me after that there may be more than one page in your projects. When I get home I will have a "Women's look" instead of a "Mans look"
Thanks again everybody for your responses, I'm off to enjoy the beautiful Sun, beaches and girls in bikinis