Initial Setup

  1. Secure your servo, one of the servo horns (your choice which one to use), and a 3 pin double sided header.
    Servo Servo horns Doublesided headers
  2. If needed, plug the servo into a 3 pin double sided header (image on the right). Doublesided headers
  3. If it is not already attached to the servo, select one of the servo horns from the plastic bag and gently press it on to the servo shaft.
    Servo Horns Servo without horns Servo with horn
  4. Connect wire jumpers from your header (the component you soldered onto your PCB) to your breadboard as shown in the table and image below. Mouse over the table below to highlight the connections. Then plug in the 3 pin header connected to the servo to the breadboard, directly beneath where the jumper wires are connected (ensure the servo is oriented correctly). Note: you do not need to use the particular colors shown for each wire. Also, note that the image shows shortened wires for clarity - your wires are longer.
    Servo Cable Color Header Socket Label
    brown or black GND
    red VOUT
    orange, yellow, white, or blue A1
    Wiring

Servo Calibration

  1. Copy the code below to your device and run it.
  2. The servo should now be alternating between spinning full-speed clockwise, stopping, spinning full-speed counterclockwise, and stopping, as indicated by text in the Mu console and on the Gizmo display. If the servo doesn't move at all, check the troubleshooting step 5. If the servo is spinning when it is supposed to be stopped, use a small Phillips screwdriver to turn the potentiometer on the underside of the servo (looks like a tiny screw head) gently in a clockwise direction. If the servo speeds up, turn the potentiometer in the other direction until the spinning stops.

    Wiring Wiring

    Once the servo stops and turns in concert with the text in the Mu console display and Gizmo display, the servo is calibrated.

Make a Robot! (GRADED)

  1. Copy the code below to your device and run it.
    1. This program enables your device to perform the “sense-think-act” cycle that all robots do by reading the temperature sensor (sense), calculating how fast to spin the servo based on that temperature (think), and then sending a signal to the servo motor to make it spin at an appropriates speed (act).
    2. First, take note of lines 75 and 85, which define “base_temp” and “min_temp_servo”, respectively. These variables define, for our program, what temperature value should correspond to the lowest motor speed (the lowest motor speed is 0).
    3. Next, look at the main loop beginning on line 87. Inside the loop, we have the code necessary to sense-think-act. Sense: Lines 92-99, Think: Lines 101-111, and Act: Line 114.
    4. Now run the program using the “Save” button. The motor is either off or spinning slowly for low temperatures (such as the ambient room temperature) and spinning rapidly for high temperatures (like when you touch the temperature sensor with a finger and heat it up).
    5. Note: Your temperature and RPM may vary from the video below depending on the room temperature
  2. Once complete, verify this with your instructor.

    Explain to your instructor where the Sense, Think, and Act steps are present in the code - this is part of your grade!

Robot Activities (GRADED)

You will be graded on your successful completion of the activities below. Starter code is provided; however, it is necessary to modify the code to complete the task. Use your experience with Python programming concepts (iteration, conditionals, order of operations, functions, etc.) and the previous examples to complete each task.
Robot Activities
  • Activity 1:
    Create a button-activated propeller! Write a program that spins the servo counterclockwise while button B is held down and clockwise while button A is held down. If neither button is pushed, the servo shouldn't rotate. You choose the speed.
  • Activity 2:
    Create a light-activated fan! Write a program that will adjust the servo's speed based on input from the light sensor. The brighter it is, the faster the servo should spin.
  • Activity 3:
    Create a tilt-activated motor! Write a program that adjusts the servo's speed based on input from the accelerometer. If the device is tipped to the left, the servo should spin counterclockwise. If it's tipped to the right, the servo should spin clockwise. The more it's tipped, the faster the servo should spin.

Verify this with your instructor. This is part of your grade! You must complete all the robot activities!

When complete with all required sensor activities AND all required robot activities, complete the DAAW Honor Acknowledgement Statement in Canvas.