aryan
Published

The home bot

This is a robot which plays a song and live stream video to you device song is to keep robbers as they will think someone is home it uses...

IntermediateFull instructions provided5 hours30
The home bot

Things used in this project

Story

Read more

Schematics

competition_bb_ovmpOvlSR9.png

Code

the python code

Python
it is used to control the robot and to execute it using ssh type
cd folder name (in pi terminal should contain the songs also in mp3)
python filename.py
import curses
import RPi.GPIO as GPIO
import os
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7,GPIO.OUT)
GPIO.setup(11,GPIO.OUT)
GPIO.setup(12,GPIO.OUT)
GPIO.setup(13,GPIO.OUT)

screen = curses.initscr()
curses.noecho() 
curses.cbreak()
screen.keypad(True)

try:
        while True:   
            char = screen.getch()
            if char == ord('q'):
                break
            elif char == curses.KEY_UP:
                GPIO.output(7,False)
                GPIO.output(11,True)
                GPIO.output(12,False)
                GPIO.output(13,True)
            elif char == curses.KEY_DOWN:
                GPIO.output(7,True)
                GPIO.output(11,False)
                GPIO.output(12,True)
                GPIO.output(13,False)
            elif char == curses.KEY_RIGHT:
                GPIO.output(7,True)
                GPIO.output(11,False)
                GPIO.output(12,False)
                GPIO.output(13,True)
            elif char == curses.KEY_LEFT:
                GPIO.output(7,False)
                GPIO.output(11,True)
                GPIO.output(12,True)
                GPIO.output(13,False)
            elif char == 10:
                GPIO.output(7,False)
                GPIO.output(11,False)
                GPIO.output(12,False)
                GPIO.output(13,False)
           if char == ord('m'):
                os.system('omxplayer -o local song1.mp3')
           if char == ord('j'):
                os.system('omxplayer -o local song2.mp3')  
finally:    
    curses.nocbreak(); screen.keypad(0); curses.echo()
    curses.endwin()
    GPIO.cleanup()

to start the streaming

Powershell
stream on vlc media player by clicking on stream in media options and in network type

rtsp://###.###.###.###:8554/ (# is ip adress)
and hit stream
raspivid -o - -t 0 -n -w 600 -h 400 -fps 30 | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8554/}' :demux=h264

Credits

aryan

aryan

2 projects • 0 followers

Comments