Step 14: Calibration & Testing
For calibrating the servo, what we need to do is narrow in on the acceptable range of motion. Meaning, we need to find the upper and lower bounds for each servo. Here is an example of a function for calibrating the beak servo. The full source code for this RoboBrrd can be found on GitHub here.
The idea behind the calibration piece of code is that the servo will slowly start to move. When it reaches the open position, you can send an ‘s’ through the Serial Monitor, and it will print what the current position is. Remember this number as it will be the lower bound.
Then send ‘g’ for the servo to move the other direction. When it reaches the closed beak, send an ‘s’ again, and remember the number to be used for the upper bound.
Now you can hard code in these numbers, and be able to use them as a reference for when you are writing to the servo.
To test the servo, we will open and close the beak with a delay of 2 seconds in between. We should check and see that the mechanism is working properly, and that the beak is able to open and close.
We will repeat this same process for the wing servos.
For the LDRs, we want to check to see if they are working. We will use the Streaming library to help us quickly print out the readings to the Serial Monitor. You can find the LDR test function in the code on GitHub.
Test the LDRs by moving your hand in front of them, or shining a bright light on them. Do the values have a noticeable difference? If not, check that the wires are plugged in.
The RGB LEDs can be tested by simply setting the various pins to LOW or HIGH.
Be sure to fix anything that is buggy or not working smoothly before moving on to the next step.