<jupyter_start><jupyter_text>`up_in_arms`Python equivalent of the `Up in arms` program. Charlie waits to be tapped. When tapped, he raises his hands, says hi, and lowers his hands. Required robot* Charlie Source codeYou can find the code in the accompanying [`.py` file](https://github.com/arturomoncadatorres/lego-mindstorms/blob/main/base/charlie/programs/up_in_arms.py). To get it running, simply copy and paste it in a new Mindstorms project. Imports<jupyter_code>from mindstorms import MSHub, Motor, MotorPair, ColorSensor, DistanceSensor, App
from mindstorms.control import wait_for_seconds, wait_until, Timer
from mindstorms.operator import greater_than, greater_than_or_equal_to, less_than, less_than_or_equal_to, equal_to, not_equal_to
import math<jupyter_output><empty_output><jupyter_text>Initialization<jupyter_code>print("-"*15 + " Execution started " + "-"*15 + "\n")
hub = MSHub()
app = App()<jupyter_output><empty_output><jupyter_text>Start hueBy turning its button off (i.e., setting its color to black) and displaying the asleep image<jupyter_code>print("Turning center button off...")
hub.status_light.on('black')
print("DONE!")
print("Displaying asleep face...")
hub.light_matrix.show_image('ASLEEP')
print("DONE!")<jupyter_output><empty_output><jupyter_text>Set motors to starting positionIn the original Scratch program, there's a `Charlie - Calibrate` block. I don't know exactly how the calibration is done, but in the end I think that it just sets the motor to position 0.Notice that moving motors to a specific position needs to be done individually (and sequentially). In other words, we cannot run a `MotorPair` to a position, only a single motor.<jupyter_code>print("Setting motors to position 0...")
motor_b = Motor('B')
motor_f = Motor('F')
motor_b.run_to_position(0)
motor_f.run_to_position(0)
print("DONE!")<jupyter_output><empty_output><jupyter_text>Raise hands when tappedAll through the execution, we will put pauses on different points to be able to see better what Charlie is doing.<jupyter_code>print("Waiting to be tapped...")

if hub.motion_sensor.wait_for_new_gesture() == 'tapped':
    print("TAPPED!")

    print("Displaying surprised face...")
    hub.light_matrix.show_image('SURPRISED')
    print("DONE!")

    wait_for_seconds(1)

    print("Raise hands...")
    motor_pair = MotorPair('B', 'F')
    motor_pair.set_default_speed(50)
    motor_pair.move(-90, unit='degrees') # Negative angle raises the hands.
    print("DONE!")

    print("Saying 'Hi!'...")
    app.play_sound('Robot 2', 75)
    print("DONE!")

    wait_for_seconds(1)

    print("Lower hands...")
    motor_pair.move(90, unit='degrees') # Positive angle lowers the hands.
    print("DONE!")

    wait_for_seconds(1)

    print("Displaying happy face...")
    hub.light_matrix.show_image('HAPPY')
    print("DONE!")
print("-"*15 + " Execution ended " + "-"*15 + "\n")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12328296703296704, 'fraction_numerical': 0.008241758241758242, 'mean_word_length': 5.318872017353579, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '192523', 'license': 'MIT', 'n_tokens_mistral': 998, 'n_tokens_neox': 944, 'n_words': 269, 'path': 'base/charlie/programs/up_in_arms.ipynb', 'repo_name': 'TheVinhLuong102/lego-mindstorms', 'size': '2912'}