I am trying to make a Lego play piano from ev3, where I have connected two arms to a single motor on either side using Lego elements. Both the arms move counterclockwise to one another (if one plays the key then another won't), the problem is that I need one of the arms to double tap on the key without the motor moving 360 degrees. How do I do it? I have used run_time, run_target, and run_angle but nothing seems to work.

this is not the picture of my product but I assembled it by watching this video. Therefore, the assembly is similar

#!/usr/bin/env pybricks-micropython
from pybricks import ev3brick as brick
from pybricks.ev3devices import *
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port
from pybricks.tools import wait

# Play a sound.

# Initialize a motor at port B.
test_motorb = Motor(Port.B) 
test_motorc = Motor(Port.C)

  • 1
    If I understand correctly, you can already tap once. What is preventing you from repeating the same movement in order to tap twice?
    – zovits
    Jan 29, 2020 at 8:35
  • 7
    Please don 't upload code as a picture. Feb 6, 2020 at 18:21
  • This is actually quite simple. Turn the motor enough degrees for it to touch the key, then use that same number of degrees to turn it back (but with a - before it to specify that it go backwards. After that, turn it that same number of degrees again but without the - this time. May 18, 2020 at 20:59


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.