8bitsandabyte
Published © CC BY-SA

The Goodbye Machine: Automate Your Goodbyes

Easily tell people how you feel with a machine!

EasyShowcase (no instructions)Over 1 day608
The Goodbye Machine: Automate Your Goodbyes

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Adafruit Massive Arcade Button RED
×1
Adafruit Massive Arcade Button Green
×1
mg995
×2
Adafruit Mini External USB Stereo Speaker
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Dremel 4300

Story

Read more

Code

code.py

Python
import RPi.GPIO as GPIO
import time as time
import os

GPIO.setmode(GPIO.BCM)

GPIO.setup(3,GPIO.OUT)
pwm = GPIO.PWM(3,60)
pwm.start(0)

GPIO.setup(2,GPIO.OUT)
pwm2 = GPIO.PWM(2,60)
pwm2.start(0)

GPIO.setup(21, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(20, GPIO.IN, pull_up_down=GPIO.PUD_UP)


def setAngleGreen(angle):

    duty = angle / 18 + 2
    GPIO.output(3,True)
    pwm.ChangeDutyCycle(duty)
    time.sleep(1)
    GPIO.output(3,False)
    pwm.ChangeDutyCycle(0)

def setAngleRed(angle):

    duty = angle / 18 + 2
    GPIO.output(2,True)
    pwm2.ChangeDutyCycle(duty)
    time.sleep(1)
    GPIO.output(2,False)
    pwm2.ChangeDutyCycle(0)


def fuckYou():
    os.system('sudo mplayer -volume 60 /home/pi/Desktop/goodbey-i-nator/FuckYou.wav &')
    for i in range(1, 8):
        setAngleRed((i*20))
    setAngleRed(10)


def playSweetGoodbey():
    os.system('sudo mplayer -volume 60 /home/pi/Desktop/goodbey-i-nator/GoodBye.wav &')
    for i in range(1, 10):
        setAngleGreen(200-(i* 10))
        time.sleep(0.15)

    setAngleGreen(200)

while True:
    input_state_green = GPIO.input(21)
    input_state_red = GPIO.input(20)
    if input_state_green == False:
        playSweetGoodbey()
    elif input_state_red == False:
        fuckYou()
        time.sleep(0.2)

pwm.stop()

Credits

8bitsandabyte

8bitsandabyte

9 projects • 6 followers
Hi, we're two makers that create stuff, which we happily share with you! Our channel: https://www.youtube.com/c/8bitsandabyte

Comments