When I started Engineering Concepts in 2020, we were required to examine the materials that I obtained for future classes. I discovered that I was missing a crucial material, a breadboard. I talked it out with my teacher and was able to clear the matter up.
Today we recieved our project of this semester; to build an automated rolling robot that can be controlled with bluetooth.
Above is the project parameters for the project. We will use this to help design our robot in the future.
Today the class learned what circuit diagrams are. They are visual display of an electrical circuit that displays how a circuit is laid out.
The purpose of a circuit diagrams are to describe circuits in detail.
Today we also used an alternate circuit diagram builder: TinkerCad. Circuit diagrams have to be electrically correct, IE. has to function if you were to build the circuit.
When the project started, we were told to research 3 examples of an autonomous servo rolling robot. These are the current research examples I have found so far.
This robotic examples goes to show how certain materials work better than others. Some materials are already shaped, while others are sturdier. This example also shows that the robot has to fit within a certain size while still containing all of the electronic portions.
While we have not discussed how bluetooth works nor how exactly it is implemented in our project, bluetooth will be used to controll the robot, so knowing how to program the robot will be important.
This is the picture diagram that our Arduino uses for the two servos and two battery packs.
This is the circuit diagram for our Arduino project. The motors are known as 'three-phase motors'.
This is my video of the Arduino servos working independantly from each other.
#include <Servo.h>
Servo myservo1;
Servo myservo2;
int pos1 = 0;
int pos2 = 0;
void setup() {
// put your setup code here, to run once:
myservo1.attach(7);
myservo2.attach(8);
}
void loop() {
// put your main code here, to run repeatedly:
for (pos1 = 0; pos1 <= 180; pos1 += 1) {
myservo1.write(pos1);
delay(15);
}
for (pos2 = 0; pos2 <= 180; pos2 += 1) {
myservo2.write(pos2);
delay(15);
}
for (pos1 = 180; pos1 >= 0; pos1 -= 1) {
myservo1.write(pos1);
delay(15);
}
for (pos2 = 180; pos2 >= 0; pos2 -= 1) {
myservo2.write(pos2);
delay(15);
}
}
This is my video of my robot rolling back and forth on the ground.
This is the picture diagram that our Arduino uses for the two servos and two battery packs.
This is the circuit diagram for our Arduino project. The motors are known as 'three-phase motors'.
This is the path that my rolling robot will take from start to end.
#include <Servo.h>
initializeServos;
int c = 0;
int f = 0;
void setup() {
setUpServos;
c = 0;
wait(5 seconds);
do{
rollFowards;
c++;
wait(0.1 seconds);
} while(c<=360);
wait(1 second);
c = 0;
do{
turnLeft;
c++;
wait(0.1 seconds);
} while(c<=30);
wait(1 second);
c = 0;
do{
rollFowards;
c++;
wait(0.1 seconds);
} while(c<=30);
wait(1 second);
c = 0;
do{
turnLeft;
c++;
wait(0.1 seconds);
} while(c<=30);
wait(1 second);
c = 0;
do{
rollFowards;
c++;
wait(0.1 seconds);
} while(c<=60);
}
void loop() {
// put your main code here, to run repeatedly:
wait(3 seconds);
c = 0;
doNothing;
}
The robot is comprised of 2 servo motors, an Arduino Uno, a breadboard, two battery packs, and several wires. The servo motors are put on either side of the robot, rotating counter-clockwise and clockwise to provide force. The servo motors have wheels attached to them, giving them additional frictional force to assist in moving.
The robot begins in the hallway, where it rolls forwards (CCW, CW) for 13 seconds, where it turns ~45 degrees to the right by rotating to the right (CW, CW) for 0.4 seconds. The robot then travels forward for an additional 7 seconds, then rotates to the left (CCW, CCW) for 0.8 seconds for a ~90 degree turn. It then travels forward for an additional 10 seconds, followed by another ~90 degree turn for another 0.8 seconds. It finally travels forward for another 10 seconds before reaching it's destination.
Originally, the robot had wooden wheels and caps cut from tubing. This was scrapped due to the wheels not being cut perfectly, and thus causing the robot the stall and not move. The original robot design was also designed out of cardboard, but was scrapped due to the cardboard being overstressed. Both of these were the cause of the robot having a wooden build body, which was much sturdier and balanced. I added washers in between the wheels to help them move smoother, but this did not work, so I planned with my dad to attach a singular front wheel by a hook to allow it to rotate. This was scrapped in favor of dismantling a toy car and using its wheels as the front wheel.
These are the labels for the wires that connect the Arduino, Breadboard, battery packs, and servo motors.
The robot begins its path by turning 90 degrees to the left, then travels forward for 5 seconds. It then rotates 180 degrees to the left, then pauses for 3 seconds, then travels backwards for 3 seconds.
Servo myservo2; //right
void setup() {
// put your setup code here, to run once:
myservo1.attach(7);
myservo2.attach(8);
delay(5000);
myservo1.write(0);
myservo2.write(0);
delay(700);
myservo1.write(50);
myservo2.write(140);
delay(5000);
myservo1.write(0);
myservo2.write(0);
delay(1300);
myservo1.write(90);
myservo2.write(90);
delay(3000);
myservo1.write(140);
myservo2.write(50);
delay(3000);
myservo1.write(90);
myservo2.write(90);
delay(10000);
}
void loop() {
// put your main code here, to run repeatedly:
myservo1.write(90);
myservo2.write(90);
delay(100);
}
Today we tested the ultrasonic sensor in our kit to detect distance away from the sensor. We are testing the sensor before attaching the sensor to our robot to determine if the sensor is functioning properly.
This is my video of my ultrasonic sensors readings.
const int trigPin = 9;
const int echoPin = 10;
float duration, distance;
void setup() {
// put your setup code here, to run once:
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
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);
delay(100);
}
A function in coding is a shortcut to a set of code that can be referenced at anytime to run that code. An example of an function in real life would be similar to how you order a pizza. You would first have to call the pizza place, figure out what you want to order, tell said order to the caller, wait for the pizza, recieve the pizza, and pay the delivery man, unless you already payed over the phone. For this example, lets calle the "function" "OrderPizza" as pseudo-code. The steps of "OrderPizza" would then be: CallPizza(Place), Find(Order), cloud Reciever ~ Order, while(Order.Position != Find(Position)){yield}, if(Order.pay != Online){PayPizzaGuy}
If/then statements are conditional functions that activate when a condition is met, such as a value being changed. An real life example of an if/then statement would be: If(self.child.homework != false)then{doHomework;}else if(self.child.chores != false)then{rankPriority(self.child.chores); doChores;}else if(self.child.homework == false && self.child.chores == false)then{procrastinate;}
void setup() {
// put your setup code here, to run once:
myservo1.attach(7);
myservo2.attach(8);
void Forward(){
myservo1.write(40);
myservo2.write(130);
}
void LeftTurn(){
myservo1.write(180);
myservo2.write(180);
}
void RightTurn(){
myservo1.write(0);
myservo2.write(0);
}
delay(5000);
Forward();
delay(13000);
LeftTurn();
delay(400);
Forward();
delay(7000);
RightTurn();
delay(800);
Forward();
delay(10000);
RightTurn();
delay(800);
Forward();
delay(10000);
}
This is my robot with it's ultrasonic sensor attached. I moved the breadboard from the front of the robot to the back of the robot, and then I wired and attached the sensor to it.
#include <Servo.h>
Servo myservo1; //left
Servo myservo2; //right
const int trigPin = 9;
const int echoPin = 10;
float duration, distance;
void Forward(){
myservo1.write(40);
myservo2.write(130);
}
void LeftTurn(){
myservo1.write(180);
myservo2.write(180);
}
void RightTurn(){
myservo1.write(0);
myservo2.write(0);
}
void setup() {
// put your setup code here, to run once:
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
myservo1.attach(7);
myservo2.attach(8);
delay(5000);
Forward();
delay(13000);
LeftTurn();
delay(400);
Forward();
delay(7000);
RightTurn();
delay(800);
Forward();
delay(10000);
RightTurn();
delay(800);
Forward();
delay(10000);
}
void check() {
// put your main code here, to run repeatedly:
do{
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);
delay(100);
} while(true == true);
}
This is the video of my robot autonomously avoiding obstacles. The first test (the firstish half of the video) I set up the obstacles incorrectly, and had to make a minor tweak in the middle of the second, but other than that it worked correctly.
This is my updated circuit diagram with both Ultrasonic Sensor, Batteries, Servos, and wiring.
#include <Servo.h>
Servo myservo1; //left
Servo myservo2; //right
const int trigPin = 9;
const int echoPin = 10;
float duration;
float distance;
void setup() {
// put your setup code here, to run once:
myservo1.attach(7);
myservo2.attach(8);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
delay(5000);
}
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){
myservo1.write(40);
myservo2.write(140);
} else {
myservo1.write(0);
myservo2.write(0);
}
delay(10);
}
#include <Servo.h>
Servo myservo1; //left
Servo myservo2; //right
const int trigPin = 9;
const int echoPin = 10;
float duration;
float distance;
void setup() {
// put your setup code here, to run once:
myservo1.attach(7);
myservo2.attach(8);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
delay(5000);
}
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){
myservo1.write(40);
myservo2.write(140);
} else {
myservo1.write(0);
myservo2.write(0);
}
delay(10);
}
This is an guide to operating the BLE part with different software.
After several attempts, a new module, and a complete rewrite of the code, I have managed to get the Arduino, my phone, and the bluetooth module to work together.
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
#include <Dabble.h>
#include <Servo.h>
Servo myservo1; //left
Servo myservo2; //right
void setup() {
// put your setup code here, to run once:
myservo1.attach(7);
myservo2.attach(8);
Serial.begin(9600);
Dabble.begin(9600);
myservo1.write(90);
myservo2.write(90);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
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() || GamePad.isDownPressed() || GamePad.isLeftPressed() || GamePad.isRightPressed()){
if(GamePad.isUpPressed()){
Serial.print("UP");
myservo1.write(40);
myservo2.write(140);
} else if (GamePad.isDownPressed()){
Serial.print("DOWN");
myservo1.write(140);
myservo2.write(40);
} else if (GamePad.isLeftPressed()){
Serial.print("Left");
myservo1.write(0);
myservo2.write(0);
} else if (GamePad.isRightPressed()){
Serial.print("Right");
myservo1.write(180);
myservo2.write(180);
}
} else {
myservo1.write(90);
myservo2.write(90);
}
delay(10);
}
The overview of a project, and the question of both "What are we making?" and "How does X work?" are parts of the Ask step of the Engineering Design Process. The Ask step is also called the Define or Idea step, where one asks "How" or "Why" something works, and comes up with an idea or plan that aims to solve that "How" or "Why" question. An overview asks several questions, from "What are the key components of the thing we are making?" to "How are we going to build ?", all of which aim to answer one or more questions that may arise when constructing a project. In this project, the overview asks questions that aim to solve the question "Why/How do gears work, and what can we do with them?"
This is a new project that we have started focusing on mechanical motion.
These are the questions that this project will awnser as we complete it.
These are the project constraints.
This is a cardboard version of a cam, a type of rotational/mechanical energy transference device, which translates a direction of motion/energy/rotation to another type or direction, such as rotational energy to linear.
You can convert rotational motion to linear motion in several ways, including cams, which is a type of mechanical transformer that converts rotational motion to linear motion, and vice versa. The wheel inside the box converts the rod's rotational motion to linear motion.
This mechanism uses LCD displays to show a timer, while a series of cams rotate behind the displays to make the LCDs move up and down.
The Concept step, also known as the Brainstorm or Research step, aims to generate numerous models/sketches/ideas of any and all types that convey a solution to the problem(s) or question(s) proposed in the Ask step. Then, you compare what ideas you have generated with other people's ideas, and brainstorm more ideas based off of them. In this project, we learned and used tools such as Ink-Scape and Tinker CAD to generate diagrams and models of gears and circuits, and compared them to other student's ideas in class.
This is my Funny Face drawing in Inkscape. I used a lot of Circles, with a single rectangle to cut the mouth.
This is my gear drawing in Inkscape.
I drew this gear in Inkscape, off of the template from the google classroom assignment. I used several circles, overlayed them, and used the difference tool on copies of the circles to make 'holes' in the gear. I used the union tool with all of the rings on the gear to group them together. I also used the align tool to get the central hole lined up.
This is my custom gear I designed in Inkscape.
This is my patterned gear in Inkscape. These were the steps used to make it.
Generate shape (polygon tool/star)
Create circle outline on gear (elipse tool + align)
Path Shape onto Outline Using Pattern (Path Effects -> Pattern)
Difference Outline onto gear (Path -> Difference)
Repeat.
The Planning step is where one defines how they are going to implement the ideas and concepts generated in the Concept step: Defining what people are involved, what tasks need to be done, what tools are going to be used, what materials are going to be needed, when tasks will be done, and so on. In this project, we planned where our gears were going to be and how we would assemble the sculpture.
This video is of my gears rotating from one driver gear. The driver gear turns the third (from the right) in the same direction, and the second and fourth gear (from the right) turn in the same direction. The driver gear turns the last gear at half the speed of the third gear (from the right).
const int motorPin = 3;
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distance;
int speed = 255;
int flag;
void setup() {
pinMode(motorPin, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trigPin, HIGH);
delayMicroseconds(2);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration*0.034/2;
Serial.print("Distance =");
Serial.print(distance);
Serial.println(" PWM");
if(distance <= 50){
analogWrite(motorPin, speed);
}else{
analogWrite(motorPin, 0);
}
}
This step of the Engineering Design Process is where details are specified, restrictions outlined, and tasks are condensed into a coherent vision. The purpose of the Design step is to translate constraints and requirements into specifications that Examples of the Design step in this project are the outlined restrictions in the overview, the size of the acrylic cut, and the designs on the gears.
The Development step of the Engineering Design Process is to take the ideas and schematics from the Planning and Design steps, and work them into working prototypes that demonstrates the solution to the requirements and restrictions outlined in the overview. This prototype can be anything from a tangible working mechanism to a intangible diagram. The Development step is also known as the Testing & Debug step, or the Invent step; as the prototypes may or may not function correctly, and may require troubleshooting. In this project, we made a hand crank-operated design that rotated all of the gears from one point. We also designed diagrams and coded a program to operate a motor and ultrasonic sensor, and combined the two designs to make an autonomously functioning robot.
The Improve step takes what was created in the Development step, and fixes bugs, enhances/optimizes parts, and generally makes things better. The Improve step often bounces back and forth between the Development step, and is often called the Testing step. In this project, I had to go back and forth from the Development step to the Improve step due to incorrectly sized gears, sensors dying, and wiring issues.
This project contains several topics relating to Science, including electrical circuits. Electrical circuits transfer energy through travelling electrons to parts of a circuit to power certain components, like a motor or light.
Like Science, this project contains a lot of topics from it, from the design process to how the motion travels from gear to gear. Gears can translate any type of physical motion to any other type of physical motion, from rotational to linear and vice versa.
This project was all about Engineering, from the process to how everything was portrayed. Through this process we went through several iterations and ultimately ended at the final model.
This project contains a few related art pieces, but not many. The designs of the gears are really what connects this to STEAM and not STEM, as each gear is unique to each other and from other projects.
This project contains a lot of math, from the measurements of the gears to the coding itself and converting from what the ultrasonic sensor sees to units of measurement. Math is a subject that fundamentally ties every other subject of STEAM or STEM together, as it defines what is precise, and how it is precise.
This school year was during the year of COVID. The most challenging part of the engineering design course was the misfortunate incidents that kept happening, like how my Ultrasonic sensor died, forcing me to replace it, or how I needed to reprint some pieces, slowing my construction process down. In the end, the thing I am most proud of is that I managed to make it