Project Brief
In this project we're going to learn about robotics and what they mean in this world.
In the end of this project I will have a moving robot that I created and I can move by coding.
Today we practiced wiring a servo using TinkerCAD, and learned where to find where the starter code is.
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
This class we wired up the servo to the arduino and we already knew how to code and wire it because of TinkerCAD.
Today I learned to make both servos move at the same time; you have to plug them into the same pin number except for GND you can to put one into the other GND pin.
Today we learned that to do independent servos you have to code two different number pins for each servo and name them differently. Then you have to plug them into the certain number pin.
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h> // this refers to a "library" that knows how to control servos
Servo firstservo; // defines a "servo" object and names it "firstservo"
Servo secondservo; // defines a "servo" object and names it "secondservo"
//int pos = 0; // variable to store the servo position
void setup() {
firstservo.attach(9); // attach the "servo" object named "myservo" to pin 9
secondservo.attach(10); // attach the "servo" object named "myservo" to pin 10
}
void loop() {
firstservo.write(0); //make the "servo" object named "firstservo" rotate at full speed counterclockwise
secondservo.write(180); //in order to make the servo go clockwise at full speed, use "180" as the number
delay(500);
firstservo.write(90); //make the "servo" object named "firstservo" rotate at full speed counterclockwise
secondservo.write(90); //in order to make the servo go clockwise at full speed, use "180" as the number
delay(500);
}
Today we learned how to move a servo with batteries only. We wired through TinkerCAD then we did it in real life. I learned that black goes in the negative and red goes to positive on the breadboard.
This is my TinkerCAD circuit diagram that we wired today.
Today we worked on our prototype and built out of cardboard. My robot has the servos, batteries, and an extra wheel for balance under the cardboard.
We started to work on our foward, backwards, left, and right code by improvising on our two independent servo code.
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h> // this refers to a "library" that knows how to control servos
Servo leftservo; // defines a "servo" object and names it "firstservo"
Servo rightservo; // defines a "servo" object and names it "secondservo"
//int pos = 0; // variable to store the servo position
void setup() {
leftservo.attach(9); // attach the "servo" object named "myservo" to pin 9
rightservo.attach(10); // attach the "servo" object named "myservo" to pin 10
}
void loop() {
leftservo.write(180); //make the "servo" object named "firstservo" rotate at full speed clockwise
rightservo.write(180); //in order to make the servo go clockwise at full speed, use "180" as the number
delay(1000);
leftservo.write(0); //make the "servo" object named "secondservo" rotate at full speed counterclockwise
rightservo.write(0); //in order to make the servo go clockwise at full speed, use "180" as the number
delay(1000);
leftservo.write(0); //make the "servo" object named "firstservo" rotate at full speed counterclockwise
rightservo.write(180); //in order to make the servo go clockwise at full speed, use "180" as the number
delay(1000);
leftservo.write(180); //make the "servo" object named "firstservo" rotate at full speed clockwise
rightservo.write(0); //in order to make the servo go clockwise at full speed, use "180" as the number
delay(1000);
// leftservo.write(90); //make the "servo" object named "firstservo" rotate at full speed counterclockwise
// rightservo.write(90); //in order to make the servo go clockwise at full speed, use "180" as the number
// delay(5000);
}
This is my robot going through the track with a code that I uploaded.
/* Sweep
by BARRAGAN <http://barraganstudio.com>
This example code is in the public domain.
modified 8 Nov 2013
by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/Sweep
*/
#include <Servo.h> // this refers to a "library" that knows how to control servos
Servo leftservo; // defines a "servo" object and names it "firstservo"
Servo rightservo; // defines a "servo" object and names it "secondservo"
//int pos = 0; // variable to store the servo position
void setup() {
leftservo.attach(9); // attach the "servo" object named "myservo" to pin 9
rightservo.attach(10); // attach the "servo" object named "myservo" to pin 10
}
void forward() {
leftservo.write(180);
rightservo.write(180);
delay(2000);
}
void backwards () {
leftservo.write(0);
rightservo.write(0);
delay(1000);
}
void left() {
leftservo.write(0);
rightservo.write(180);
delay(1000);
}
void right() {
leftservo.write(180);
rightservo.write(0);
delay(1000);
}
The wiring was kind of difficult because it was different from the servo wiring. This is my ultrasonic sensor working in the serial monitor.
This is my robot avoiding walls, and we did this by using our void code. When we had the void code we added an ultrasonic sensor to code, and wire.
We used dabble for the controls and we combined the code from forward, back, right to the dabble code.
At first the backside of my robot was higher than the front, so the front was being dragged. After I fixed the balance on my robot, only one of my servos were working so I had to fix the wiring on the breadboard.
In Arduino we had to download Dabble so we could have the code for the LED bluetooth.
After we connected our robot to our Dabble app, we had to traverse a path. We got bonus points for hitting the wall less than 6 times and by doing clockwise 360s and counterclockwise 360s.
For this project we are going to use and learn about different power tools.
When using the table saw you need to wear safety goggles, no loose clothing, if you need to move anything use a push stick. Do not operate with gloves on , leave it plugged in, don't leave without vacuuming.
Today we used the table saw to cut 2x4 into flat boards for our box
Removes material from the top of the material to perform. Reduce thickness, makes the material a uniform material, and make it smooth. You have to wear safety protection, don't put fingers near the opening.
We put our 2x4 boards into the planner to make it skinnier
Secure material with your hand outside of the hand placement line, don't move the the blade guard, plug in saw the cord across body.
We measured before we cut at the lines we made.