SOS Example
We used this example to learn about functions in Arduino. In this example, there are two functions that are later used in the loop. Using functions saves time and code writing.
Single Motor
Then, we attached the motors to the Arduino and ran the example program Single Motor. This program runs only one motor and results in the wheel moving backward and forward. We took this program as a starting point and modified it to create our next programs.
Double Motor
This program runs both motors at the same time and speed, so that the wheels of the sciborg move together and it will travel in a (hopefully straight) line. We modified the original Single Motor program by adding the second motor and setting its speeds exactly the same as the first motor.
Minimum Speed
Next, we tested out different speeds on the sciborg. We determined the lowest possible speed that made our sciborg still move was around 50.
Here is our sciborg moving incredibly slow!
Hard Turn
Now that we had our sciborg moving in a straight line, we had to figure out how to turn it. First, we made the sciborg do a hard turn, essentially spinning it around in place. To do this, we have each motor running at the same speed in opposite directions.
Gentle Turns
Since we don't want it to turn so abruptly, we needed to find how to implement some more gentle turns. First, we had the sciborg go forward, turn a little, go forward, turn a little, and repeat. This was successful, but resulted in a somewhat jerky turn.
The next gentle turn we tried out was smoother than the first. One motor was set slightly faster than the other. The result was the at the sciborg turned in a small circle.
10 feet
Next, we programmed our sciborg to travel exactly 10 feet. We initially did this using the delay, finding just the right amount of time for the vehicle to move 10 feet. After this determined time, which we found to be 9 seconds, we stopped the motor. In our testing, the sciborg traveled the 10 feet exactly almost every time. If it was off, it usually was short of 10 ft by about 2-3 cm.
Motor Button
After creating and testing some basic programs, Olivia and I started work on our biggest task of the day: when the sciborg hits an obstacles it backs up, turns, and continues on its way.
First, we needed learn how the Lego motor button worked, so we ran the example program Motor Button on our sciborg. When the button is pressed, the motors stop, and when it is released, the motors start again. In the following video, the motors have been set to opposite speeds, so the sciborg turns one way direction, then when the button is pressed and let go of, it turns the other direction.
Hitting a Wall
Now that we had played around with the motor button, we started on the code for hitting the wall. This code makes the sciborg move straight, then when the button is pushed (it hits the "wall"), the sciborg backs up and turns. Then the loop restarts and the sciborg continues straight until it hits something else. For testing, we attached the motor button to the front of the sciborg.
Nice work on the blog post! Everything was clear and your descriptions were very easy to understand and read. Is there a reason why it says VIDEO OF 10 FEET above Motor Button though? Just wondering
ReplyDeleteThat was a reminder for me to put in the video of the sciborg traveling 10 feet! It's been updated now.
DeleteI like how you laid out your post and it was very clear how you modified each sketch when going through each task.
ReplyDeleteYour sciborg moved very impressively on the Hitting a Wall part! Great job!
ReplyDeleteYour post is super easy to follow and laid out very comprehensively. I enjoyed watching your videos! Nice work!
ReplyDeleteReading this I realized how much each of the different sciborgs have little unique quirks that our codes have to account for. For example our sciborg's minimum speed was around 57.
ReplyDelete