What's a Microcontroller Digital Input-Pushbuttons
microcontrolleruser
Posts: 1,194
Sorry.
Had to back off the Stepper Motor plan for now.
Was getting in over my head.
Okay. Will work on Button Press.
Had to back off the Stepper Motor plan for now.
Was getting in over my head.
Okay. Will work on Button Press.
Comments
Here's the source code from Stamp Editor BS 1 programs.
Mike
Have a heart!
Debounce routines are where I was up to with PIC Assembler tutorial.
Nasty. Nasty. Nasty.
Mike
What does this program do?
Is it only checking once for button press?
I am going to look in What's a Microntroller.
Just for a little more information. Not a lot!
That was a bad idea.
I am going to just stick with this example.
How do I wire up button as 'active low' button?
It's a parallax breadboard button.
Important note for this to work: Btn must be an alias for a PINx variable. This allows the line after the PAUSE to accumulate the debounced timing if the button is pressed, or reset it to zero if the button input is low. Remember: In the BS1, there is no operator precedence; expressions are evaluated left to right. In this case, five is added to timer and then multipled by the state of the button pin. If the button is pressed, Btn evaluates as 1 and the timer accumulates; if the button is released then Btn evaluates as 0 and the timer variable is cleared.
I was at LA Comic Con yesterday and saw lots of Cosplays with boring LEDs. Even the BS1 can spice things up with a simple bit of code. Here's a real-world program that I use as a demo for the Prop-1 controller with a trainer board (which has 6 LEDs and a button).
The complete listing is attached so you don't have to re-type it. One of the "advanced" things you'll notice is that the loops use different pins -- this prevents the bounce delay on the ends of the strip of LEDs.
One button contact to ground, the other to the I/O pin, and a pullup resistor (~10K) to Vcc.
Kwinn
Thank you.
Found Prop example. Got out of it because there was too much going on in it.
Your explanation will work fine.
Keeping it simple.
Jon
Thanks!
Let me get this going 'as-is'.
Then look at your ideas.
EFX-TEK (I co-created) has sold a couple thousand Prop-1 (industrialized BS1) controllers across the world from everyone to home Halloween decorators to major amusement parks that you've probably visited. In fact, there is a Christmas tree on display at a very famous SoCal amusement park that has 80 Prop-1 controllers creating a faux candle effects. My customers aren't looking for ideas, they're looking for solutions that work in their applications.
You can continue to post blurbs from the (20 year old) help file, but those are not proving that you're learning anything, nor are you providing any new information for other forum members.
Jon
Okay.
Will finish this experiment tomorrow.
Changing over to Basic Stamp 2 What's a Microcontroller button experiment.
Need step by step through this.
Going to go look for a Homework board.
Here's my standard BS2 template for the EFX-TEK Prop-2 controller -- note that it does debouncing in a loop and allows the user to specify active-high or active-low trigger input.
Thank you Jon
Still working my way up to that point.
Right now.
Will the Parallax Serial to USB adapter work with the Basic Stamp Homework boards?
Parallax pushes it for the Stamp 1 Project board but not the Homework boards.
Wondered if there was a snag there.
EFX-TEK (JonnyMac's company) does have a USB to BS1 adapter that takes the place of a USB to Serial Adapter plus a Serial to BS1 Adapter.
Here's another tidbit.
Light on Homework board is a 'programming activity' light.
Light on BOE is 'board powered' light.
Have time to notice these things now. At least for a little while.
Have two Serial Homework boards.
Okay. Parallax Serial to USB works with them.
Light on board did light up while program downloaded and then went off.
Will continue this later.
And here's a generic USB-to-TTL adapter connected with jumper wires.
Yes, both work. In fact, the USB2SER thing is what caused me to create the USB-BS1 Serial Adapter for EFX-TEK.
Thanks Jon
Ran a 'Print to Terminal' program and it worked.
USB to Serial only is for communication. It does not provide USB power.
So. Terminal program with Identify reported COM port 4 but no stamp.
Had to put battery in Homework board.
Yes. That looks like a good USB to TTL board.
Fixed the title.
Will build circuit tomorrow.
'Test Pushbutton'.
Get used to that 4 lead pushbutton.
Ken
Let me get back to you about that.
We're on a roll here.
Will build 'test button' circuit here shortly.
Actually caught on to the part about 'pull down' and 'pull up' resistor.
It's the 10K one on the 'opposite leg' of main circuit.
Funny way to put it but that's the gist of it.
(Fixed typo -- thanks, Dave)
A pull-down is used when the input signal is active-high.
A pull-up is used when the input signal is active-low.
In breadboard experiments we tend to use active-high inputs because it's easier to think of having a "high" signal as on.
Why use an input with a pull-up? Well, in the industrial world there are a lot of sensors and devices with "open-collector" outputs. This means that the output looks disconnected until active; when active the sensor provides a connection to ground which pulls the input down. You just have to remember that when reading the pin "1" is off, and "0" is on.
Another area where pull-ups are used is the I2C bus between the processor and EEPROM. The pull-up creates the "1" state on the bus and either end can connect to ground to provide the "0" state.
Did you mean pull-up on both statements?
Will put some of the lesson circuits together today and post pic's.
One problem with these older boards is they run the serial port out the top.
That was for serial and parallel ports coming out the back of desktops.
Now with tower's under the desktop and laptops you want the USB connector on the bottom of the board.
I have to run the cable around to the top to keep board 'right side up'.
I have to put a block of steel on the cable to keep the heavy cable from dragging little board off the table.
Waah!
Found a pushbutton and mounted it on breadboard.
Here's pushbutton test circuit.
It works.
Next is 'Turn LED off with pushbutton'.
It does not look like 'pull-down' or 'pull-up' circuit.
Looks like a shunt one.
-- https://www.parallax.com/product/28030