pyMCU test project looks like a Minecraft mob

pymcu-controlled-blockhead

Hackaday’s own [Jeremy Cook] has been testing out the pyMCU board and managed to put together an animated block head that looks like it could be a foe in Minecraft. That’s thanks mostly to the block of foam he’s using as a diffuser. The face of the project is a set of LEDs. These, along with the servo motors that move the neck are controlled using Python code which you can glance at after the break (there’s a video demo there too).

We first saw pyMCU early in the year. The PIC 16F1939 offers plenty of IO and acts as a USB connected bridge between your hardware and your Python scripts. Speaking of hardware, the test platform used to be an RC helicopter. [Jeremy] scrapped most of it, but kept the servo motors responsible for the pitch of the rotors. The board makes these connections easy, and the concept makes controlling them even easier. In fact, there’s only about 17 lines of code for the functions that control the servos. The rest is a simple UI built with Tkinter.

# File: hello2.py

from Tkinter import *
import pymcu    # Import pyMCU module

mb = pymcu.mcuModule()  # Create a new pyMCU class object from first found pyMCU board

class App:

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()

        self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)
        self.button.pack(side=LEFT)

        self.servos_up = Button(frame, text="nod up", command=self.nod_up)
        self.servos_up.pack(side=LEFT)

        self.servos_down = Button(frame, text="nod down", command=self.nod_down)
        self.servos_down.pack(side=LEFT)

        self.tilt_left = Button(frame, text="tilt left", command=self.tilt_left)
        self.tilt_left.pack(side=LEFT)

        self.tilt_right = Button(frame, text="tilt right", command=self.tilt_right)
        self.tilt_right.pack(side=LEFT)

    def nod_up(self):
        print "nod up"
        mb.pinHigh(1)
        mb.pausems(20)
        mb.pulseOut(11,1300,20)
        mb.pinHigh(2)

    def nod_down(self):
        print "nod down"
        mb.pulseOut(11,800,20)
        mb.pinLow(1)
        mb.pinLow(2)

    def tilt_left(self):
        print "tilt left"
        mb.pulseOut(10,1000,20)

    def tilt_right(self):
        print "tilt right"
        mb.pulseOut(10,1600,20)

root = Tk()

app = App(root)

root.mainloop()

Comments

  1. wow hackaday is responsive. wow!

  2. Taylorian says:

    awesome use of a trainer kit for an RC chopper. Never would have thought of using that as legs.

  3. Joejoedancer says:

    FTDI USB to UART chips make me angry!!!!!

  4. ssdjlmnop says:

    creepy bot is creepy

    i was expecting it to walk too…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 92,441 other followers