Writing the code
The code for the mechanical bird will use the ultrasonic sensor as both the eyes and to trigger movement. The goal is to mimic a bird in flight looking for prey, so we will work to ensure the legs move with the head gesture as well as the wing mechanics.
The ports
You will connect the ultrasonic sensor into port B. You will plug the large motor into port F. You will plug the two medium motors into ports C and D.
Calibrating the motors
This first code stack will make sure that the head and wing motors are all set to position 0 before being activated to ensure everything works smoothly and properly:
- Under the when program starts block, insert a purple light up block that activates the lights on ultrasonic sensor B lighting up to 0 0.
- Add a pink movement block named set movement speed to and make it 15%.
- Add a blue set speed to motor block, set it to 10%, and change it to...