Bluedot – Bluetooth and the 4-tronix Initio Robot.

IMG_1595Some time ago, I wrote about Bluedot – and now I’ve used this to control the Initio robot.

Bluedot consists of two parts – an App and some Python code which runs on the Raspberry Pi. The Initio takes a variety of Raspberry Pi’s, but I recently received some PTFA funding to upgrade to a Pi3 for the club robot so that it would more effectively run Scratch.

Setting up Bluedot is easy – I then took the demonstration program from the Bluedot website and added GPIO commands into the mix.

While my preference is to have robots running autonomously, using sensors to find their way around (And the Initio certainly excels at this), having an App control the motors is certainly fun and a very immediate way of creating a remote control vehicle.

From here? Perhaps a Web cam streaming images to a remote monitor… Watch this space!

 

 


from bluedot import BlueDot
from signal import pause

import time, RPi.GPIO as GPIO

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(19, GPIO.OUT)
GPIO.setup(21, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(26, GPIO.OUT)

def dpad(pos):
    if pos.top:
        print("up")
        print("Both Forward")
        GPIO.output (26, 1)
        GPIO.output (21, 1)
        GPIO.output (19, 0)
        GPIO.output (24, 0)

    elif pos.bottom:
        print("down")
        GPIO.output (26, 0)
        GPIO.output (21, 0)
        GPIO.output (19, 1)
        GPIO.output (24, 1)

    elif pos.left:
        print("left")
        GPIO.output (26, 1)
        GPIO.output (21, 0)
        GPIO.output (19, 1)
        GPIO.output (24, 0)

    elif pos.right:
        print("right")
        GPIO.output (26, 0)
        GPIO.output (21, 1)

    elif pos.middle:
        print("fire")
        GPIO.output (19, 0)
        GPIO.output (21, 0)
        GPIO.output (24, 0)
        GPIO.output (26, 0)

bd = BlueDot()
bd.when_pressed = dpad

pause()
Advertisement