<p>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 <code>run_time</code>, <code>run_target</code>, and <code>run_angle</code> but nothing seems to work.</p>
<p><a href="https://i.sstatic.net/Sv4Jz.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Sv4Jz.png" alt="this is not the picture of my product but I assembled it by watching this video. Therefore, the assembly is similar" /></a></p>
<pre><code>#!/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)
</code></pre>

CC BY-SA 4.0
2020-01-29T08:35:06.753Z
If I understand correctly, you can already tap once. What is preventing you from repeating the same movement in order to tap twice?
zovits
CC BY-SA 4.0
2020-02-06T18:21:28.563Z
Please [don 't upload code as a picture](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557).
H. Pauwelyn
CC BY-SA 4.0
2020-05-18T20:59:42.083Z
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.
mindstormsboi
<ev3><programming><python><pybricks>
How do I make a single arm double tap a piano key?
Bishes Upadhyaya
# How do I make a single arm double tap a piano key?

(Asked by: username_0 on 2020-01-28)

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.

#!/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)

**Tags:** ev3, programming, python, pybricks

> **Comments:**
> **username_1**: If I understand correctly, you can already tap once. What is preventing you from repeating the same movement in order to tap twice?  
> **username_2**: Please [don 't upload code as a picture](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557).  
> **username_3**: 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.  

---

## 0 answers

