Working Stargate Universe Moc using EV3

I created a working Stargate Universe Moc with an EV3.
It is possible to choose how far the Gate spins for each chevron and you can dial adresse with 7-9 chevrons.

Video:

20 Likes

Nice… Custom code?

1 Like

Used Micro-Python(Lego Education Version) for the project

1 Like

Ah. So, yes.

 #!/usr/bin/env pybricks-micropython

from pybricks import ev3brick as brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
                                 InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import (Port, Stop, Direction, Button, Color,
                                 SoundFile, ImageFile, Align)
from pybricks.tools import print, wait, StopWatch
from pybricks.robotics import DriveBase

#gears 16,12,140 (teeth count of the gears)
#118°~90° input=>output
#36 Symbols for universe gate
#4*118°/36Symbols ~ 13.1°/Symbol

gate_motor = Motor(Port.A,Direction.CLOCKWISE,[16,12,140])

 def spinToSymbol(symbolNumber=4,spin=False):
    if spin:
        symbolNumber *= -1
    gate_motor.run_target(80,symbolNumber * 13.1)

def getButtonInput():
    while not any(brick.buttons()):
        wait(10)
    buttonInput = brick.buttons()
    brick.light(Color.YELLOW)
    while any(brick.buttons()):
        wait(10)
    brick.light(None)
    return buttonInput[0]



def getSymbols():
    symbols = []
    symbols.append(9)

    def printSymbols():
        brick.display.clear()
        brick.display.text("Symbols:",(60,50))
        for i in(range(len(symbols))):
            brick.display.text(str(i+1)+"."+str(symbols[i]))
        brick.display.text("Left:-",(0,10))
        brick.display.text("Right:+",(0,20))
        brick.display.text("Down:Next Symbol",(0,30))
        brick.display.text("Center:Dial",(0,40))

    i = 0
    while True:
        printSymbols()
        nextInput = getButtonInput()
        if nextInput==16: #LEFT
            if symbols[i] > 0:
                symbols[i] -= 1
        elif nextInput==64: #RIGHT
            symbols[i] += 1
        elif nextInput==4: #DOWN
            if symbols[i] > 0:
                i += 1
                if i >= 9:
                    return symbols
                    break
                symbols.append(9)
        elif nextInput==32: #CENTER
            if i >= 6 and symbols[i]>0:
                return symbols
                break

def dialGate(symbols=[4,4,4,4,4,4,4]):
    def printDialingDialog(chevron=3,encoding=False):
        if encoding:
            chevron -= 1
        brick.display.clear()
        brick.display.text("Start Dialing Gate:",(8,35))
        for i in range(chevron):
            brick.display.text(" Chevron "+str(i+1)+" locked")
        if encoding:
            brick.display.text(" Chevron "+str(chevron+1)+" encoded")

    brick.display.text("Start Dialing Gate:",(8,35))
    brick.light(None)
    spin=True
    addressLength=len(symbols)
    if addressLength <=9:
        for i in(range(addressLength)):
            printDialingDialog(i+1,True)
            spinToSymbol(symbols[i],spin)
            if spin:
                spin=False
            else:
                spin=True
            brick.light(Color.RED)
            brick.sound.file('chevron2.wav')
            wait(200)
            printDialingDialog(i+1,False)
            wait(400)
            brick.light(None)
    if addressLength>=7 and addressLength <=9: 
        brick.sound.file('gate_open.wav')
        brick.display.text("Wormhole established")
        getButtonInput()
        brick.sound.file('gate_close.wav')
    else:
        brick.display.text("DIALING FAILED!")

symbols=getSymbols()
dialGate(symbols)
1 Like

I wish i knew python. I only know Java and C#, and only very basic amounts of that.

I don’t get what it’s supposed to be, but good job with the EV3!

Better Video from the Show:

1 Like