In this project we are going to learn about robotics and how they influence the world.
At the end of this project I will have a rolling robot that I can move and control with my phone.
Today we practiced wiring a servo using Tinkercad, we also learned where to find our own starter code.
Today we coded a physical servo to move back and forth.
I have coded two servos together in unison, they are placed on the same pins and are not separate.
I have coded two servos to move back and forward independently(separate pins).
#include <Servo.h> // incude in any code that incudes servos
Servo firstsrevo; //define a servo object and names it "firstsrevo"
Servo secondservo; // definded a "secondservo"
// int pos = 0;
void setup() {
firstsrevo.attach(9); //taches servo obecect to pin 9
secondservo.attach(8);
}
void loop() {
firstsrevo.write(0); //servo "firstsrevo" rotates full speed couter clockwises
secondservo.write(180); //in order to make the servo go clockwise at full speed use 180 as number
delay(1000);
firstsrevo.write(180);
secondservo.write(0);
delay(1000);
}
Today we powered our servos with batteries. We now have the freedom to move around with the robot.
This is the circuit diagram we built.
This is my prototype body for my robot. The design is made out of cardboard and is meant to have good center of gravity.
I coded my robot to move forward backwards and left and right.
#include <Servo.h> // incude in any code that incudes servos
Servo rightservo; //define a servo object and names it "firstsrevo"
Servo leftservo; // definded a "secondservo"
// int pos = 0;
void setup() {
rightservo.attach(9); //taches servo obecect to pin 9
leftservo.attach(8);
}
void loop() {
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(1000);
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
delay(1000);
//turn left
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(0); //0 fowrds 180 back
delay(2000);
//turn right
rightservo.write(1800); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
delay(2000);
}
I programed my robot to follow a predesigned path. along the way i made some changes one of them being I turned the bread board around because it was hard to reach with where the battery pack was. The main code changes I made were at first the directions were off with left and right, but after I figured out how to turn each way the main changes I made were time changes.
#include <Servo.h> // incude in any code that incudes servos
Servo rightservo; //define a servo object and names it "firstsrevo"
Servo leftservo; // definded a "secondservo"
// int pos = 0;
void setup() {
rightservo.attach(9); //taches servo obecect to pin 9
leftservo.attach(8);
}
void loop() {
// foward
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(3000);
//backwards
// rightservo.write(0); // 180 foward 0 backwards for robot
// leftservo.write(180); //0 fowrds 180 back
delay(1000);
//turn right
rightservo.write(1800); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
delay(800);
// foward
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(2500);
//turn right
rightservo.write(1800); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
delay(740);
// foward
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(3150);
//turn left
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(0); //0 fowrds 180 back
delay(770);
// foward
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(4400);
//turn right
rightservo.write(1800); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
delay(730);
// foward
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(5800);
//turn left
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(0); //0 fowrds 180 back
delay(725);
// foward
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(5750);
//turn left
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(0); //0 fowrds 180 back
delay(820);
// foward
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
delay(4000);
}
#include <Servo.h> // incude in any code that incudes servos
Servo rightservo; //define a servo object and names it "firstsrevo"
Servo leftservo; // definded a "secondservo"
// int pos = 0;
void setup() {
rightservo.attach(9); //taches servo obecect to pin 9
leftservo.attach(8);
}
void foward(){
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
}
void backwards(){
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
}
void left(){
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(0); //0 fowrds 180 back
}
void right(){
rightservo.write(1800); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
}
void loop() {
foward();
delay(1000);
backwards();
delay(1000);
left();
delay(2000);
right();
delay(2000);
}
I got an ultra sonic sensor to tell how far things are from the robot.
/*
* Ultrasonic Sensor HC-SR04 and Arduino Tutorial
*
* by Dejan Nedelkovski,
* www.HowToMechatronics.com
*
*/
// defines pins numbers
const int trigPin = 5;
const int echoPin = 6;
// 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);
}
I coded a ultra sonic sensor to move forward and turn when it senses a wall or object.
#include <Servo.h> // incude in any code that incudes servos
//sensor define
const int trigPin = 5;
const int echoPin = 6;
// defines variables
long duration;
int distance;
Servo rightservo; //define a servo object and names it "firstsrevo"
Servo leftservo; // definded a "secondservo"
// int pos = 0;
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
rightservo.attach(9); //taches servo obecect to pin 9
leftservo.attach(8);
}
void foward() {
rightservo.write(180); //servo "firstsrevo" rotates full speed couter clockwises
leftservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
}
void backwards() {
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
}
void left() {
rightservo.write(0); // 180 foward 0 backwards for robot
leftservo.write(0); //0 fowrds 180 back
}
void right() {
rightservo.write(1800); // 180 foward 0 backwards for robot
leftservo.write(180); //0 fowrds 180 back
}
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 < 6){
right();
delay(765);
foward();
}
// foward();
// delay(1000);
// backwards();
// delay(1000);
// left();
// delay(2000);
// right();
// delay(2000);
}
I built a gearbox, this makes the robot faster. Gearboxes increase the rotations per minute of the child gear.
I was able to control my Arduinos light through Bluetooth. I was not able to control the light that was in the bread board.
This robot Runs off one gear box in the back and has a drive shaft in the box. The front two wheels are connected by a wooden dowel glued to a angular servo.
The body was too wide so I had to shave down the base and cut indents in the bottom for wheels and servos.
I added a lot of jutted out pieces to give the robot a junkyard feel. I changed the main body a little but I kept it mostly the same and added complemtary colors.
I coded a servo to look for devices and then control my robot when it is connected to a device.
My robot is controled by bluethoth and is able to make it through the course.
Locked box project
The table saw is used to make long straight cuts . You must wear safety glasses ,remove lose clothing, use a rip fence and use a feather board. Do not cross cut with the rip fence or put you fingers within 6" of the blade. remove triping hazards and gloves before use. Never stand in front of the blade. Today we used it to cut 2x4 into smaller pieces.
WHile using the planer wear ear protecion and saftey glases. While using it adjust the material to 1/16" of the material thickness before cuting, unpug after , and vacum after. Dont use any other material than wood through it and dont put your hadns near the oppning. the planner removes the top of meterials it does this to make the material smotth and make it have a unifor thickness.4
THe miter saw cuts up and down and is used to make wood shorter. When uing it wear saftey glases,unpulg after use, keep wood secure and reduce the exposure of you had to the blade. Dont touch use the blade gurd and dont mesure while using the mechine.
Makes hoes in materials to help assemble your box. while using wear safety glassmaker sure the size is right ,set the highest in the middle of the material, mark both sides of the material, clamp a block infront of material. Never put your fingers near the blade while pugged in assume the blade wont come out of the material.
In Onshape i have learned how to make simple sketches and use the sketch tools in a beginner setting.
#include <Servo.h> // incude in any code that incudes servos
//sensor define
const int trigPin = 5;
const int echoPin = 4;
// defines variables
long duration;
int distance;
Servo driveservo; //define a servo object and names it "firstsrevo"
Servo steer; // definded a "secondservo"
// int pos = 0;
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
driveservo.attach(9); //taches servo obecect to pin 9
steer.attach(8);
steer.write(90);
}
void foward() {
driveservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
}
void backwards() {
driveservo.write(180); //0 fowrds 180 back
}
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 < 20) {
steer.write(110);
delay(765);
backwards();
delay(1500);
steer.write(90);
}
foward();
// steer.write(180);
//delay(250);
//steer.write(90); //180 left 0 right 90 middle
//delay(250);
// foward();
// delay(1000);
// backwards();
// delay(1000);
// left();
// delay(2000);
// right();
// delay(2000);
}
/*
Gamepad module provides three different mode namely Digital, JoyStick and Accerleometer.
You can reduce the size of library compiled by enabling only those modules that you want to
use. For this first define CUSTOM_SETTINGS followed by defining INCLUDE_modulename.
Explore more on: https://thestempedia.com/docs/dabble/game-pad-module/
*/
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
#include <Dabble.h>
#include <Servo.h>
Servo steer; // definded a "secondservo"
Servo driveservo; // definded a "secondservo"
void setup() {
// put your setup code here, to run once:
Serial.begin(250000); // make sure your Serial Monitor is also set at this baud rate.
Dabble.begin(9600); //Enter baudrate of your bluetooth.Connect bluetooth on Bluetooth port present on evive.
driveservo.attach(9);
steer.attach(8);
steer.write(90);
}
void foward(){
driveservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
}
void backwards(){
driveservo.write(180); //0 fowrds 180 back
}
void loop() {
Dabble.processInput(); //this function is used to refresh data obtained from smartphone.Hence calling this function is mandatory in order to get data properly from your mobile.
Serial.print("KeyPressed: ");
if (GamePad.isUpPressed())
{ foward();
Serial.print("UP");
}
if (GamePad.isDownPressed())
{ backwards();
Serial.print("DOWN");
}
if (GamePad.isLeftPressed())
{ steer.write(110);
Serial.print("Left");
}
if (GamePad.isRightPressed())
{ steer.write(60);
Serial.print("Right");
}
if (GamePad.isSquarePressed())
{
Serial.print("Square");
}
if (GamePad.isCirclePressed())
{ driveservo.write(90);
steer.write(90);
Serial.print("Circle");
}
if (GamePad.isCrossPressed())
{
Serial.print("Cross");
}
if (GamePad.isTrianglePressed())
{ steer.write(90);
Serial.print("Triangle");
}
if (GamePad.isStartPressed())
{
Serial.print("Start");
}
if (GamePad.isSelectPressed())
{
Serial.print("Select");
}
Serial.print('\t');
int a = GamePad.getAngle();
Serial.print("Angle: ");
Serial.print(a);
Serial.print('\t');
int b = GamePad.getRadius();
Serial.print("Radius: ");
Serial.print(b);
Serial.print('\t');
float c = GamePad.getXaxisData();
Serial.print("x_axis: ");
Serial.print(c);
Serial.print('\t');
float d = GamePad.getYaxisData();
Serial.print("y_axis: ");
Serial.println(d);
Serial.println();
}
/*
Gamepad module provides three different mode namely Digital, JoyStick and Accerleometer.
You can reduce the size of library compiled by enabling only those modules that you want to
use. For this first define CUSTOM_SETTINGS followed by defining INCLUDE_modulename.
Explore more on: https://thestempedia.com/docs/dabble/game-pad-module/
*/
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
#include <Dabble.h>
#include <Servo.h>
Servo steer; // definded a "secondservo"
Servo driveservo; // definded a "secondservo"
void setup() {
// put your setup code here, to run once:
Serial.begin(250000); // make sure your Serial Monitor is also set at this baud rate.
Dabble.begin(9600); //Enter baudrate of your bluetooth.Connect bluetooth on Bluetooth port present on evive.
driveservo.attach(9);
steer.attach(8);
steer.write(90);
}
void foward() {
driveservo.write(0); //in order to make the servo go clockwise at full speed use 180 as number
}
void backwards() {
driveservo.write(180); //0 fowrds 180 back
}
void loop() {
Dabble.processInput(); //this function is used to refresh data obtained from smartphone.Hence calling this function is mandatory in order to get data properly from your mobile.
Serial.print("KeyPressed: ");
if (GamePad.isUpPressed())
{ foward();
Serial.print("UP");
}
if (GamePad.isDownPressed())
{ backwards();
Serial.print("DOWN");
}
if (GamePad.isLeftPressed())
{ steer.write(140);
Serial.print("Left");
}
if (GamePad.isRightPressed())
{ steer.write(50);
Serial.print("Right");
}
if (GamePad.isSquarePressed())
{
Serial.print("Square");
}
if (GamePad.isCirclePressed())
{ driveservo.write(110);
steer.write(90);
Serial.print("Circle");
}
if (GamePad.isCrossPressed())
{
Serial.print("Cross");
}
if (GamePad.isTrianglePressed())
{ steer.write(110);
Serial.print("Triangle");
}
if (GamePad.isStartPressed())
{
Serial.print("Start");
}
if (GamePad.isSelectPressed())
{
Serial.print("Select");
}
Serial.print('\t');
int a = GamePad.getAngle();
Serial.print("Angle: ");
Serial.print(a);
Serial.print('\t');
int b = GamePad.getRadius();
Serial.print("Radius: ");
Serial.print(b);
Serial.print('\t');
float c = GamePad.getXaxisData();
Serial.print("x_axis: ");
Serial.print(c);
Serial.print('\t');
float d = GamePad.getYaxisData();
Serial.print("y_axis: ");
Serial.println(d);
Serial.println();
}
planner
lock Research
I wouldn't build the lock on a large scale but the lock being scaled up helped me understand how it works. There is a center lock core that sits in another cylinder. there are pins that drop down into the center core that would free spin without these pins. A key is inserted in to the center cylinder and pushes the pins up to allow the center cylinder to rotate. This lock is feasible in class(scaled down) by using 3d printers .
This lock is a password lock made using Arduino a screen and a numpad. I would have to order a numpad and led screen to be able to make the lock. I would also use different locking mechanism probably i would use the Arduino Door lock below an use the keypad to actuate the Arduino.
The lock above works with a wedge key and rubber bands pulling two sliding doors. The lock is able to be made in class and the lock is pretty simple to make.
This lock is made by using a Arduino and a normal pin door lock. We have the materials in class and the lock should be easy to make and feasible to do.
https://create.arduino.cc/projecthub/BuildItDR/bluetooth-door-lock-arduino-bc2035
Do wear gloves, use a drop cloth, put a small amout of stain on the rag, use a cotton cloth
donts mix stanis, leave staning materials ou,leave stain rags out waste glovs
Lock /prototyping
Lock evaluation and testing
This is a rough sketch of the lock i am going to create and all the parts it contains. The materials are at the bottom.
This lock is made by using a Arduino and a normal pin door lock. We have the materials in class and the lock should be easy to make and feasible to do.
https://create.arduino.cc/projecthub/BuildItDR/bluetooth-door-lock-arduino-bc2035
THese are screenshots of the front lock face, one of the rotors, and the actuator arm. These all were lasre cut.
THis is the final assembled class lock. In the video i talk about how the lock functions and some of the parts and mechanics used in i.
This day i spent coding, As well as perfecting the angles of the code.
This is my prototype lock, the bolt i made out of cardboard. The only part of the lock that will changes the bolt as it is the only moving part of the lock. the bolt will be metal and will be mounted inside m box.
This day i made the on shape files for the lock. I cut the files as well.
This was the first laser cut version of my lock. I then used the same file but laseer cuted the lock out of wood.
This is the final lock and the mounted version. It is laser cut out of wood.
IN this video I explain how the lock works as well as present the lock.
This is my ML and the body poster. In this poster I talk about how Facebook Ai advertisement.
Machine learning is the act of coding and telling a ai what is what. You provide a data set to ai and in that data set are images that are labeled for the ai. After the ai has looked over and process the images it will be able to predict the label for each image. Think of machine learning as raising a child, children become imprints of there parents as the parents taught them and molded them. that is exactly what a coder does to a machine learning algorithm.
In my model I identify house hold items, ones normally found in the kitchen. With my model i hoped to identify each item with a acuracy of 90% or above.
These are the items I used for my data set. When creating a data set you put each item in front of a camera and take photos to put in a google drive as you data. There are 250 images per item making total of 1,000 48x48 images.
This is my final machine learning model. It has a 100 percent correct prediction rate. This model is able to recognize a spoon, fork ,knife, and a can. The model is a machine larnin model and is written in python.
This section of code builds and shows a summary of the model. Ost of the code is importing the keras model and setting the size of said model. After creating defining layer size and setting output of a dense layer you summarize the model.
In this example you can see the Ai predicting what the image is based off the data set. The model has a 100% accuracy rate so there are no mislabel images