X
    Categories: Projects

Button Trigger for Google Assistant on Raspberry Pi

This is a quick tutorial on adding button trigger for google assistant on raspberry pi, this tutorial was very straight forward and should take that much time to perform to add this action.

○○○ Parts ○○○

Momentary Switch ► http://amzn.to/2qUoGf2

LED ► http://amzn.to/2qkgBnP

resistor 220 ohm ► http://amzn.to/2pfiAto

USB Microphone ► http://amzn.to/2qCx4zY

Raspberry Pi 3 ► http://amzn.to/2oquADd

Installing the RPi.GPIO

pip install RPi.GPIO

edit google samples assistant main.py file

nano /home/pi/env/lib/python3.4/site-packages/googlesamples/assistant/__main__.py

on the top of the file we need to import gpio

import RPi.GPIO as GPIO

now we have to setup our pins

GPIO.setmode(GPIO.BCM)

GPIO.setup(18,  GPIO.IN, pull_up_down=GPIO.PUD_UP)

GPIO.setup(23, GPIO.OUT)

now we need to add the trigger to our code at line 197

comment out with #click.pause…..

input_state = GPIO.input(18)

if input_state == True:

GPIO.output(18,False)

continue

else:

GPIO.output(18,True)

pass

remember to double check the indents, google likes to use 4 spaces in place of tab spacing.

if you want more details about this project, consider checking out one of my previous post about installing google assistant on raspberry pi

Google Assistant on Raspberry Pi

novaspirit: Avid Thinker, Computer Programmer, Web evangelist, Hacking / Breaking expert, Problem Solver, Technology Obsessed, Gamer, 3D printing, Coffee lover!

View Comments (16)

Related Post