Frau HmpfFiona Murray
Published © GPL3+

Raspi Lego Pumpkin Beautifier

This hellish device is not just for Halloween. You might want to enhance Easter eggs and Christmas tree ornaments or scratch your cat.

BeginnerWork in progress3.5 hours749
Raspi Lego Pumpkin Beautifier

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Explorer HAT Pro
×1
Jumper wires (generic)
Jumper wires (generic)
×8
DC motor (generic)
×2

Hand tools and fabrication machines

Lego

Story

Read more

Code

Pen and platform spin

Python
from time import sleep
import explorerhat
from random import *
import threading

# contol pen spin

def spin_pen_forward (channel, event):
    t = threading.Thread(target = spin_pen_forward_t)
    t.start()
    
def spin_pen_forward_t ():
    duration = 10
    print(duration)
    http://explorerhat.motor.one .forward(50)
    sleep(10)
    http://explorerhat.motor.one .stop()

http://explorerhat.touch.one .pressed(spin_pen_forward)

# control pumpkin spin
def spin_pumpkin_forward (channel, event):
    t = threading.Thread(target = spin_pumpkin_forward_t)
    t.start()

def spin_pumpkin_forward_t ():
    duration = random()
    print(duration * 5)
    explorerhat.motor.two.forward(15)
    sleep(duration * 5)
    explorerhat.motor.two.stop()

def spin_pumpkin_back (channel, event):
    t = threading.Thread(target = spin_pumpkin_back_t)
    t.start()

def spin_pumpkin_back_t ():
    duration = random()
    print(duration * 5)
    explorerhat.motor.two.backward(15)
    sleep(duration * 5)
    explorerhat.motor.two.stop()

explorerhat.touch.three.pressed(spin_pumpkin_forward)
explorerhat.touch.four.pressed(spin_pumpkin_back)

#thread.start_new_thread(explorerhat.touch.three.pressed(spin_pumpkin_forward))
#thread.start_new_thread(http://explorerhat.touch.one .pressed(spin_pen_forward))

Credits

Frau Hmpf

Frau Hmpf

3 projects • 16 followers
working where the wild things are a.k.a. teacher @ primary school
Fiona Murray

Fiona Murray

1 project • 1 follower
Primary School Teacher
Thanks to Martin O'Hanlon.

Comments