We hit 300 blog views today!
Today we are working on a combination of the Arduino and a Lego racer (with a much better motor):
Partner: Rachel Hwang
a) making functions -- an effective way to reuse code rather than copy and pasting. In this exercise, we had a dot() function and a dash() function that were called in order to execute a SOS message with an LED and Arduino.
b) set up the sciborg
- attach the battery pack & Arduino
- instal Bricktonics Lego NXT
- use NXT cables to connect the motor and motor port
- plug the Arduino into the computer and download the necessary libraries
Behold! The dreaded SCIIIIBORGGGGG!!! (doesn't this thing remind you of that gross baby-head spider creature from toy story?) Coincidence? I. Think. NOT.
*scream in the background*
c) work with your SciBorg (just getting the single motor file to run on my computer was, in itself, a challenge with a buttload of error messages, still unresolved to this day)
1. Single Motor -- In this exercise, we downloaded code from Amy Banzaert (our professor) and ran it. Basically, the code tells the Arduino we are dealing with only one motor and that we want to turn it at a speed of 75 (forward slow), then 255 (forward fast), -75 (backwards slow), -255 (backwards fast). Note: In the serial console, the behavior of the wheel will be printed out as it is occurring (see code).
2. Both Motors -- (all together now, ladies) In this exercise, we edited the single motor code so that we were controlling both motors. Then we copy and pasted the code for motor one and changed it to be controlling motor two.
Serial Console Output (the 2 denotes the printout of the second motor)
3. Minimum Speed -- through experimentation (trial and error), we found the minimum speed that would move the Sciborg (100 (sorry, speed units currently unavailable)). This was not too difficult, but we did hit a couple of road blocks when one of our wheels (the left one) wouldn't always turn...
4. Hard Turn -- Set one motor to full power forward and one to full power in reverse. This had the effect of a very sharp, minimal turning radius, turn.
5. Soft Turn -- Make the sciborg take a gentler turn. (This was unclear whether we were supposed to just lower the speed but still have the two motors/wheels turning in opposite directions to achieve a turn or to increase the turning radius as it was executed)
Same turning radius as Task 4, just lower speed and longer time period to execute the turn.
Jerky, wider radius turn. (Further iteration is required to achieve a wider radius smooth turn.) Possible problems: the inside wheel is turning at a faster rate than the outside wheel is (because the outside wheel has to cover more distance, creating a jerking motion)
6. Traveling 10 feet
Step 1:
Set the speed of both motors to high (255) and time how long it takes to travel 10 feet. (See code from Task 2 for how to set the speed to 255)
Result: about 11 seconds
Proof:
Step 2:
Write a sketch to get the Sciborg to travel for that amount of time (11 seconds) and then stop.
Result: The Sciborg didn't make it to the line because it didn't travel perfectly straight or on an identical path as it did in step 1. (See further notes below)
In this trial our sciborg did not travel in a perfectly straight line (uneven floor?), but stopped about 2 inches from the line. The Sciborg did not stop exactly at the line because it is going on a timed run, rather than based on sensing from the environment whether it has reached a line or not.
In this trial, we attempted to keep the sciborg's path a straight line. We did not alter any of the code, and the course was the exact same as before. Oddly enough, the sciborg dramatically veer off to the left. Reason: unknown.
(its alive)
As you can see, we often struggled with getting the bot to start. (he's pretty stubborn, I think I'll name him Stew. Stubborn Stew.)
Skills:
- #moar coding
- functions
- morse code #SOS
- working with motors
- set run times with motors
- using millis() and loop()
(hehe, sorry, I couldn't resist)
Yikes! Sciborgs are freaky! Will give me nightmares.
ReplyDeleteEnjoy reading your blogs. :-).
Thanks! Glad you enjoyed it!! :)
ReplyDelete