loading

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

For this tutorial you will need:

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)

GPIO.setup(23, GPIO.OUT)"

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

GPIO.output(23,False)

continue

else:

GPIO.output(23,True)

pass"

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.

<p>I have problem, when i write this code i have error:</p><p>pi@raspberrypi:~ $ source env/bin/activate</p><p>(env) pi@raspberrypi:~ $ python -m googlesamples.assistant</p><p>Traceback (most recent call last):</p><p> File &quot;/usr/lib/python3.4/runpy.py&quot;, line 151, in _run_module_as_main</p><p> mod_name, mod_spec, code = _get_module_details(mod_name)</p><p> File &quot;/usr/lib/python3.4/runpy.py&quot;, line 118, in _get_module_details</p><p> return _get_module_details(pkg_main_name)</p><p> File &quot;/usr/lib/python3.4/runpy.py&quot;, line 126, in _get_module_details</p><p> code = loader.get_code(mod_name)</p><p> File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1572, in get_code</p><p> File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1532, in source_to_code</p><p> File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 321, in _call_with_frames_removed</p><p> File &quot;/home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py&quot;, line 322</p><p> GPIO.output(23,False)</p><p> ^</p><p>IndentationError: expected an indented block</p><p>(env) pi@raspberrypi:~ $ </p>

About This Instructable

2,112views

42favorites

License:

Bio: Avid Thinker, Computer Programmer, Web evangelist, Hacking / Breaking expert, Problem Solver, Technology Obsessed, Gamer, 3D printing, Coffee lover!
More by novaspirittech:Voice Activated Google Assistant for Raspberry Pi Google Assistant on a Raspberry Pi Button Trigger for Google Assistant on the Raspberry Pi 
Add instructable to: