In this project, we will learn about robotics and their importance in the world around us.
By the end of this project, I will have a functioning robot that i am able to control with my phone
Today we learned how to wire a servo and make it move back and forth and where to find the code for it.
/* 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
}
}
Today we used Arduino to code our servo to move. We wired up our breadboard following the code to make it move.
We were able to make two servos move at the same time. With using the same code but plugging the new set of wires into a different hole, but different location on the breadboard to get it to work.
We were able to add on to the code to make two servos work on their own. By duplicating some of the code and changing the numbers to say we have added another servo move on its own.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
Servo myservo2;
// 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
myservo2.attach(10);
}
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
}
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo2.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
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
On tinkercad we modeled out how we would use battery power to power our servos. With this it gave us a visual on what to do with our physical model.
Today in class we were able to power our servos with batteries. By removing the blue wire the connected our Arduino to the computer, adding on more wires and battery packs, We were able to control both our servos with batteries.
Today in class we were able to take cardboard and make a robot body. We added our servos and battery to make a functioning robot.
#include <Servo.h>
Servo servoright; // create servo object to control a servo
Servo servoleft;
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
servoright.attach(9); // attaches the servo on pin 9 to the servo object
servoleft.attach(7);
}
void loop() {
servoleft.write(0);
servoright.write(180);
delay(1000);
servoleft.write(180);
servoright.write(0);
delay(1000);
servoleft.write(180);
servoright.write(180);
delay(1000);
servoleft.write(0);
servoright.write(0);
delay(1000);
}
In class we were able to change our code to do forward, backward, left, right. When uploaded to our robot it was able to move in these directions correctly.
#include <Servo.h>
Servo servoright; // create servo object to control a servo
Servo servoleft;
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
servoright.attach(9); // attaches the servo on pin 9 to the servo object
servoleft.attach(7);
}
void loop() {
servoleft.write(180);
servoright.write(180);
delay(5000);
servoleft.write(0);
servoright.write(90);
delay(1200);
servoleft.write(180);
servoright.write(180);
delay(8000);
servoright.write(90);
delay(1100);
servoleft.write(180);
servoright.write(180);
delay(5000);
servoleft.write(90);
servoright.write(180);
delay(1900);
servoleft.write(180);
servoright.write(180);
delay(3000);
servoleft.write(0);
servoright.write(90);
delay(1700);
servoleft.write(180);
servoright.write(180);
delay(5000);
}
Over a few days of trial and error we were able to code our robot to go on a set path. With our knowledge of how it code the arduino forward, backward, left, right, we played with the delay on our code to get it to turn and move at the correct times.
#include <Servo.h>
Servo servoright; // create servo object to control a servo
Servo servoleft;
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
servoright.attach(9); // attaches the servo on pin 9 to the servo object
servoleft.attach(7);
}
void forward(){
servoleft.write(0);
servoright.write(180);
}
void backward(){
servoleft.write(180);
servoright.write(0);
}
void left(){
servoleft.write(180);
servoright.write(180);
}
void right(){
servoleft.write(0);
servoright.write(0);
}
void loop() {
forward();
delay(1000);
backward();
delay(1000);
left();
delay(1000);
right();
delay(1000);
}
We were able to wire up an Ultrasonic Sensor to our arduino and bread board. It was able to work correctly.
/*
* Ultrasonic Sensor HC-SR04 and Arduino Tutorial
*
* by Dejan Nedelkovski,
* www.HowToMechatronics.com
*
*/
// defines pins numbers
const int trigPin = 9;
const int echoPin = 7;
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
}
During the class we were able to alter our code to have an if then statement. Now if our robot is close to an object, it will move then continue on its course. With the gear boxes, we were able to assemble or pieces and with this gadget, it works to make our wheels spin faster. With the parent gear guiding the smaller gear, it turns our wheels faster without having to increase the size of the wheels.
#include <Servo.h>
Servo servoright;
Servo servoleft;
const int trigPin = 4;
const int echoPin = 5;
long duration;
int distance;
void setup() {
servoright.attach(9);
servoleft.attach(7);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void forward() {
servoleft.write(180);
servoright.write(180);
}
void backward() {
servoleft.write(180);
servoright.write(0);
}
void left() {
servoleft.write(180);
servoright.write(180);
}
void right() {
servoleft.write(0);
servoright.write(0);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.println(distance);
if (distance < 3) {
right();
delay(1250);
forward();
}
}
#include <Servo.h>
Servo servoright;
Servo servoleft;
const int trigPin = 4;
const int echoPin = 5;
long duration;
int distance;
void setup() {
servoright.attach(9);
servoleft.attach(7);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void forward() {
servoleft.write(180);
servoright.write(180);
}
void backward() {
servoleft.write(180);
servoright.write(0);
}
void left() {
servoleft.write(180);
servoright.write(180);
}
void right() {
servoleft.write(0);
servoright.write(0);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
Serial.print("Distance: ");
Serial.println(distance);
if (distance < 3) {
right();
delay(1250);
forward();
}
forward();
delay(60000);
}
Functional Requirements:
Limited to no slipping --currently not meeting/currently meeting/currently can't evaluate
Weight must be balanced --currently not meeting/currently meeting/currently can't evaluate
Must be stable --currently not meeting/currently meeting/currently can't evaluate
Avoids walls/objects when desired --currently not meeting/currently meeting/currently can't evaluate
Can be controlled by bluetooth --currently not meeting/currently meeting/currently can't evaluate
Can fit into bin (width and length only) --currently not meeting/currently meeting/currently can't evaluate
Usability Requirements:
Fully enclosed . --currently not meeting/currently meeting/currently can't evaluate
Has a removable door/ cover. --currently not meeting/currently meeting/currently can't evaluate
Has easy access to batteries. --currently not meeting/currently meeting/currently can't evaluate
Has easy access to red row/5V. --currently not meeting/currently meeting/currently can't evaluate
Has easy access to the reset button. --currently not meeting/currently meeting/currently can't evaluate
Has easy access to the "B" end of the A-B Cable --currently not meeting/currently meeting/currently can't evaluate
Aesthetic Requirements:
Pieces and parts match up --currently not meeting/currently meeting/currently can't evaluate
Clean Glue Edges --currently not meeting/currently meeting/currently can't evaluate
Design is unique --currently not meeting/currently meeting/currently can't evaluate
Complimentary Colors are Implemented --currently not meeting/currently meeting/currently can't evaluate
#include <Servo.h> // this refers to a "library" that knows how to control servos
Servo rightservo; //defines a "servo" object and names it "firstservo"
Servo leftservo; //defines a "servo" object and names it "secondservo"
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(0); //make the "servo" object named "firstservo" rotate at full speed counterclockwise
rightservo.write(180);
}
void backwards(){
leftservo.write(180); //make the "servo" object named "firstservo" rotate at full speed counterclockwise
rightservo.write(0);
}
void left(){
leftservo.write(180); //make the "servo" object named "firstservo" rotate at full speed counterclockwise
rightservo.write(180);
}
void right(){
leftservo.write(0);
rightservo.write(0);
}
void loop() {
forward();
delay(5000);
backwards();
delay(5000);
left();
delay(5000);
right();
delay(5000);
forward();
delay(1450);
}
Today in class we learned how to set up our Bluetooth module. With this we were able to get a small light on our Arduino to light up with our phone controlling it.
This is the final robot body. My robot was able to be coded to move avoid objects. With creating functions to code the servo to get the gear boxes to move, in addition to the motion sensor getting the robot to avoid objects in its path.
This is my finalized robot design.
In the back is where we access the wiring.
The top is a place were you can hold things with its design almost as a large pick up truck.
Here demonstrates my final robot progress. My robot is being controled by my phone using the dabble app, and my robot is coded to where if a certain button is clicked, it will contenue in that direction till the stop funtion is clicked. From using this app i was able to comtrol my robot on a set course throughout our classroom enviroment.
This decries the requirements for our lockbox project
This shows all the box benchmarks that we are going to need for this project.
This shows all the lock benchmarks that we are going to need to document for this project.
The table saw cuts wood along the length of the wood, its called a rip cut. It only cuts straight lines
Do: wear safety glasses, remove loose clothing, use push stick
We cut long planks of wood in half along its length. We took turns running the wood through the blade and pulling the wood at the end out.
It removes the material from the top of the material to preform function, reduces thickness, makes it uniform and makes it smooth and nice.
Do: wear ear/eye protection, adjust cutting thickness, unplug when done
We took our planes of wood we cut the other day and ran them through. With running the wood multiple times, getting both sides, we were able to smooth out and uniform our pieces of wood so they can be used.
Cuts across the length of the wood. This type of cut is the cross cut.
This can also cut at angles(used to make frames
Do: where safety glasses, unplug after, reduce exposure to blade
We measured the dimensions we wanted for our box and used this tool to cut our wood pieces. By lining our piece to the desired length, we lower the blade to get our precise cut.
cuts "biscuit shaped" holes on your material so that you can assemble your parts to be both
Perfectly allied
Sturdy
Once you biscuit, you glue your parts creating what's is called a "glue up"
Do's: wear safety glasses, set to appropriate size, mark both sides
It uses inputs from a CAD file to cut, or carve parts/pieces.
Most expensive tool !
Programs: VCARVE PRO- used to develop simple designs for cutting
Onshape files: used for more complex designs
Shopbot: controls the machine and runs cad files
Do's: run dust collector, vacuum after, secure your material(crews or clamps), design around your schools
Dont's: Leave the CNC while its running, going near the gantry while its running
Smooths out flaws and prepares wood for sanding (smooths out wood surfaces). It can resolve edges that didn't perfectly match up
Do: wear safety glasses, keep sander moving at all times, be careful to not put sander on skin
Do: wear gloves, stain over a drop cloth, a small amount of stain on your rag, & to use a cotton cloth when staining
Don't: mix stains, leave the material out, waste gloves
create your file in Onshape
right click on the file(or sketch) and click export to DFX
login to glowforge
click create new
click upload
select file
for cardboard select 1/8" corrugated cardboard
How does it work?
You have to move it about 2 rounds clockwise then like the back rotor up with the bar, going counter clockwise to not mess up the last one, go to the 2nd rotor(your set number) and finally go clockwise again to your last rotor and when you flip the dial it will open. You have to go CW, CCW, then CW again so all the rotors can catch onto each other and successfully open the lock.
Is it feasible in class and why?/ Does it meet the constraints for this project and why?
Yes, all the materials needed to make this can be made and cut out of wood and the laser cutter. The parts can be man made and designed in onshape so its able to be made in class, and meets the requirements.
How does it work?
It works within the code. Its coded so if the key button is clicked 1st, then you can enter in the code. If the code is not correct it will not open. To reset you would need to clear what your mistake or to start over its coded so that if you click the designated button, if clicked it will wipe what you previously put in so you can start again. After you click the designed start button, the code says "if" that correct code is entered, the lock will open.
Is it feasible in class and why?/ Does it meet the constraints for this project and why?
No, we do not have all the necessary materials materials. It uses an Arduino and is coded to work and you would manually need to fix the wires so it can work properly.
How does it work?
It works by having a key made to open the lock. There are pins down within a board to keep the lock closed. When the key is inserted, it pushes those pins up moving its own grooves into the spots in which the pins once were. After the key is in place, you pull up and out on the key to remove the block that is keeping the lock, locked.
Is it feasible in class and why?/ Does it meet the constraints for this project and why?
Yes, this is made with different materials that can be used and found around the classroom. The mechism can also be added to our boxes without casuing damage to what we have already done with it. The different components can be made on onshape and cut or messured out by hand and cut by hand.
How does it work?
It works with a latch and magnet. The latch is connected to one side with a magnet attached. A key is used to open it and the key is a magnet aswell. When the magents attract, the latch goes down, and you are able to open it.
Is it feasible in class and why?/ Does it meet the constraints for this project and why?
Yes, using different resorses you can create a latch. You can design it online using onshape and put the peices together so it can be functional and used. It can be made out of wood or 3D printed in addition to the magnets.
There is a magnet on hook/latch and its weighted down by a washer in the resting position. The key is a small wood box with another magnet attacked. The key magnet latches to the inside magnet on the hook, and once the key magnet is moved, it moves the hook out of resting position to open the box.
With learning the program Onshape, we were able to design out pieces for our combo lock. We were given the design and using the tools within the program, we recreated them. Upon making them in Onshape, our designs were able to be sent to the laser cutter, so the set pieces can be cut out to create our lock.
This is the finished class combo lock. Comparing the template to the final product, they are about identical. We put together out lock using out laser cut pieces and wood glue. We align the 3 routers, with the stoppers attached, with spacers on the dowel, and put it in our lock. We make our dial and connect it to our routers so they can turn. This is so we are able to put in a combination and open the lock. The actuator has the bar and sits on the bolt, so when the handle it turned when the rotors are all aligned at the bar, it pulls the bolt back and the lock opens.
Today I got most of my prototype pieces made. They were made out of cardboard. I was able to make the hook and the latch the hook would be on when in lock position. The box in which the magnet for the key was also made as well. Must was done today, next step is to test.
Today I tested new magnets to see what will hold and move the hook within the box. I attached the latch to the top and created a new lock design to see what will work best.
Today in class I leaned about the website makercase and put in the detentions for the case around my physical lock, and the key
Today I also digitally fabricated the hook fro my lock in onshape.
I took time out of class to put the hinges on my box. Now my lid and box is connected and can open properly.
I modified my onshape file during this class period.
Now that the hook was on a levy method of movement, holes were needed and a wall on which the dowel can pass through.
This is the final lock. The magnets are the key to the lock box. When the outside magnet interacts with the magnet attached to the hook, it rotates on the dowel to the given latch. When inside the latch, the box is locked, and when the hook is moved away with the magnet the box is then unlocked.
In class we make 2 posters for space is the new place. My 1st poster talks about and of our class focuses, which is Supervised Learning, and the other is a informational poster on Snapchats face recognition machine learning model.
I'm identifying a: LunchBox,
PencilCase,
Phone,
and WaterBottle
For data collection I took 200, 48x48 pixel photos of our objects
There are 200 photos of each
This is my Final Model. We had to find four objects, take a variety of photos of select objects, and create a machine learning model where they can be identified. The model is able to pull from my google drive folder "accessories", where all the images of of the objects are placed, to provide for the model. We were able to code this model to train and test so it can be able to predict and label each image. From what I've learned I was able to get the model to predict with 100% percent accuracy, so there is no mistakes when it comes to predicting/ labeling the image.
This block of code shows the model layers and summary. The dense layers are a number of objects, which is 4, and a SoftMax function. The other is the size 1024 and a sigmoid activation function. This is summing up what the code and model is explaining.
Accurate showing and prediction of the lunchbox
Accurate showing and prediction of the phone
Accurate showing and prediction of the waterbottle
The images above means the machine learning model was able to accurately predict and show the correct image. Because my model has 100% (1.00) accuracy there is no mislabeled images. That means there are nowhere where the prediction from the model and the true image will not match. The prediction the model makes will always match the given image.