I am currently working on this week’s project for Physical Computing and I am running into some issues with servo motors. Specifically, how I can do other things while the servo motor is running.
First, I’ll go over what I’ve done so far to check that certain parts of my circuit and code are definitely working. I started by making a circuit to control the servo using a potentiometer. Before putting in a servo, I used an LED to make sure I wired the potentiometer correctly.
Next, I swapped out the LED for my servo and updated my code to use the servo library.
All of this was working great. So I know for this week’s project I want to have a servo that will go through its motion and then return to the original position after it completes its travel. I am able to get this working as shown below.
And then because I will have an option (via push buttons) to choose a slow or fast speed, I want the LED to blink either fast or slow accordingly. I added the LED blinking code using delays, but it slows down my servo’s motion to a crawl.
I know it’s going through the delays each time it loops to move my servo, so I am looking into ways to avoid using delays to get my LED to blink. Or is it only possible stop the slowing down by running one output at a time? I doubt it, so I’m going to keep looking into solutions.