2

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.
brick.sound.beep()

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

test_motord.run_target(500,-180)
test_motord.run_time(500,2000)
wait(1000)
test_motord.run_target(500,0)
test_motord.run_time(500,2000)
3
  • 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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.