AeroFixerB1
Posts: 19
Joined: Wed Mar 27, 2019 3:36 am

Setting up a Start Program Button

Wed Mar 27, 2019 3:44 am

Hello,

I'm pretty new to this and I'm learning every step of the way.
I'm using a Pi Zero W for a new project and my goal with the project is to have the Pi run a program for a Plastic scale model. My plan is to have the program simulate the engine starting in the plane by having the program turn a motor with the prop attached in conjunction with audio of the engine starting and running.

What I now need to do is set up a start program button. So basically someone can come up to the displayed model, push the button, the program will start, run and then stop and wont start again until someone pushes the button again.

Where should I start with this?

please I need all the help I can get thank you

User avatar
B.Goode
Posts: 8045
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Setting up a Start Program Button

Wed Mar 27, 2019 10:33 am

Welcome to the Raspberry Pi forums.

The gpiozero Python library module installed by default with the Raspberry Pi Foundation Raspbian Stretch Operating System might be a good starting point.

There is documentation for a simple Start/Stop button here: https://gpiozero.readthedocs.io/en/stab ... rolled-led

klricks
Posts: 6499
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Setting up a Start Program Button

Wed Mar 27, 2019 12:35 pm

A RPi Zero W does not have an audio output jack so in order to have audio you will need to have an HDMI TV/monitor attached.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

AeroFixerB1
Posts: 19
Joined: Wed Mar 27, 2019 3:36 am

Re: Setting up a Start Program Button

Wed Mar 27, 2019 5:44 pm

klricks wrote:
Wed Mar 27, 2019 12:35 pm
A RPi Zero W does not have an audio output jack so in order to have audio you will need to have an HDMI TV/monitor attached.
I understand and ive already got a solution for that problem by getting a HAT from adafruit to allow me to attach speakers.

AeroFixerB1
Posts: 19
Joined: Wed Mar 27, 2019 3:36 am

Re: Setting up a Start Program Button

Wed Mar 27, 2019 5:47 pm

B.Goode wrote:
Wed Mar 27, 2019 10:33 am
Welcome to the Raspberry Pi forums.

The gpiozero Python library module installed by default with the Raspberry Pi Foundation Raspbian Stretch Operating System might be a good starting point.

There is documentation for a simple Start/Stop button here: https://gpiozero.readthedocs.io/en/stab ... rolled-led
Yes ive read this before but the problem is this isnt a simple start stop button.

User avatar
B.Goode
Posts: 8045
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Setting up a Start Program Button

Wed Mar 27, 2019 5:48 pm

AeroFixerB1 wrote:
Wed Mar 27, 2019 5:44 pm
klricks wrote:
Wed Mar 27, 2019 12:35 pm
A RPi Zero W does not have an audio output jack so in order to have audio you will need to have an HDMI TV/monitor attached.
I understand and ive already got a solution for that problem by getting a HAT from adafruit to allow me to attach speakers.


In which case be aware that attaching the audio HAT might impede your access to the J8 40-way header on your RPi needed to connect the Start button.

User avatar
B.Goode
Posts: 8045
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Setting up a Start Program Button

Wed Mar 27, 2019 5:50 pm

AeroFixerB1 wrote:
Wed Mar 27, 2019 5:47 pm
B.Goode wrote:
Wed Mar 27, 2019 10:33 am
Welcome to the Raspberry Pi forums.

The gpiozero Python library module installed by default with the Raspberry Pi Foundation Raspbian Stretch Operating System might be a good starting point.

There is documentation for a simple Start/Stop button here: https://gpiozero.readthedocs.io/en/stab ... rolled-led
Yes ive read this before but the problem is this isnt a simple start stop button.

It's just a Start Button.... Surely not that difficult to adapt having been given something base a solution on?

pcmanbob
Posts: 6412
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Setting up a Start Program Button

Wed Mar 27, 2019 6:09 pm

I think what you actually need is to have your program running but wait for a button press to execute turning the motor and playing the engine sound.

So the program would work like this.

Program start
Set up gpio for output for motor control
Set up gpio for button input
Check button status
If not pressed wait 0.5 seconds and check again
If pressed then
Start motor to spin propeller and play the motor sound
Wait 25 seconds
Stop motor and stop sound
Go back to checking the button.

So the button checking , motor control & play sound all happens within the running program.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

AeroFixerB1
Posts: 19
Joined: Wed Mar 27, 2019 3:36 am

Re: Setting up a Start Program Button

Fri Mar 29, 2019 12:17 am

pcmanbob wrote:
Wed Mar 27, 2019 6:09 pm
I think what you actually need is to have your program running but wait for a button press to execute turning the motor and playing the engine sound.

So the program would work like this.

Program start
Set up gpio for output for motor control
Set up gpio for button input
Check button status
If not pressed wait 0.5 seconds and check again
If pressed then
Start motor to spin propeller and play the motor sound
Wait 25 seconds
Stop motor and stop sound
Go back to checking the button.

So the button checking , motor control & play sound all happens within the running program.
Yes! This sounds exactly what I need to do thank you so much!

Return to “Beginners”