Introduction: Button Trigger for Google Assistant on the Raspberry Pi
On this Instructablel I will be showing you how you can add a button trigget to your Google Assistent, which is running on your Raspberry Pi.
Hope that you like it and thanks
Step 1: Get Everything Ready
Step 2: Connect Everything to the Raspberry Pi
Connect the momentary switch to Ground (3rd pin from right to left on the bottom row) and to the GPIO18.
Connect the LED Light to Ground (8th pin from right to left on the bottom row) and to the GPIO23.
Step 3: Download Our Dependencies
Get intot he Raspberry Pi with Raspbian on it and open up the Command Prompt.
Type in "source env/bin/activate" and then press "Enter"
Once we are inside our enviroment, type "pip install RPi.GPIO" and press "Enter"
Step 4: Edit the Googlesamples File
On the Command Prompt, type in "geany env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py"
Once the Geany editor opens, scroll down after the last "import" and create a new line.
Type in ""import RPi.GPIO as GPIO"
Scroll down to the Line 37 and type in "GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN pull_up_down=GPIO.PUD_UP)
Scroll all the way down to the Line 196.
Comment out the code in the Line 196 by adding an "#" to the start of the code.
NOTE: Remember that Python works by tabs, but the file is indented by spaces, so keep in mind, 1 Tab = 4 Spaces
Create a new line over the code you just commented out and type in "input_state = GPIO.input(18)
if input_state == True
Save the file and close it.
Step 5: Enjoy Your Button Trigger
Go back to the Comand Prompt.
Type in "python -m googlesamples.assistant" and press "Enter"
You can now press your button and talk to your your Google Assistant in a Raspberry Pi.
And that's it, now you can wake up your Google Assistant in the tap of a button, literally.