Today we learned how to connect a servo to an Arduino with attached code that makes the servo rotate.
/* 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 learned how to properly assemble a circuit (containing a servo, an arduino, and a bread board) that rotates a servo back and forth. In order for it to spin, I had to connect wires from the bread board to the servo and then run the code above.
Today we also connected a second servo to the circuit, and now both servos are following the same pattern/code simultaneously.
This time, I had to add lines of code in order for the servos to operate independently. The code included copying and pasting the functions and switching the pin from 9 to 10.
/* 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 is a preprogrammed library that helps control servos
Servo myservo; // this defines the servo and names it myservo
Servo myservo2; // this defines the servo and names it myservo
// 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); // 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
}
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
}
}
Today we learned how to power two servos with four batteries using many wires, an arduino, and a breadboard.
Screenshot of Tinkercad Model Circuit
Today I created a prototype for my servo robot, using cardboard, my circuit, and two independently operating servos.
Today we learned how to program the robot to move forward, back, left and right, exactly in that order.
Today I finally adjusted and finalized the code for the robot's full path of the track.
/* 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 is a preprogrammed library that helps control servos
Servo leftservo; // this defines the servo and names it myservo
Servo rightservo; // this defines the servo and names it myservo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
leftservo.attach(9); // attaches the servo on pin 9 to the servo object
rightservo.attach(10); // attaches the servo on pin 9 to the servo object
}
void loop() {
leftservo.write(0); // tell servo to go to position in variable 'pos'
rightservo.write(180);
delay(4850); // waits 15ms for the servo to reach the position
leftservo.write(180);
rightservo.write(180);
delay(490);
leftservo.write(0); // tell servo to go to position in variable 'pos'
rightservo.write(180);
delay(5000);
leftservo.write(180);
rightservo.write(180);
delay(600);
leftservo.write(0); // tell servo to go to position in variable 'pos'
rightservo.write(180);
delay(3500);
leftservo.write(0);
rightservo.write(0);
delay(925);
leftservo.write(0); // tell servo to go to position in variable 'pos'
rightservo.write(180);
delay(2650);
leftservo.write(0);
rightservo.write(0);
delay(790);
leftservo.write(0); // tell servo to go to position in variable 'pos'
rightservo.write(180);
delay(6000);
leftservo.write(0);
rightservo.write(0);
delay(800);
}
Today we created gearboxes for our servos and I learned that the gearboxes actually make the wheels move faster.
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
/*
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> // 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
// 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.
}
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 stop (){
leftservo.write(90);
rightservo.write(90);
}
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())
{
Serial.print("UP");
forward();
}
if (GamePad.isDownPressed())
{
Serial.print("DOWN");
backwards();
}
if (GamePad.isLeftPressed())
{
Serial.print("Left");
left();
}
if (GamePad.isRightPressed())
{
Serial.print("Right");
right();
}
if (GamePad.isSquarePressed())
{
Serial.print("Square");
}
if (GamePad.isCirclePressed())
{
Serial.print("Circle");
}
if (GamePad.isCrossPressed())
{
Serial.print("Cross");
}
if (GamePad.isTrianglePressed())
{
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();
}
Today I finally figured out how to program my ultrasonic sensor to miss walls at a certain distance.
Today we connected a Bluetooth module to our robot in order to control it on our phones using an app called dabble.
Today I learned how to correctly wire a the ultrasonic sensor to my robot, which is a distance sensor that helps the robot avoid walls. The next step is to upload the code that commands the servos to turn when the sensor comes within a certain distance of a wall.
I tested the functionality of my robot, where the wheels were limited to no slipping, it was moving swiftly, and the robot body has a sound build.
I made my robot this shape because it mixes a square with a triangle, which creates a unique design. It is also a sound design in terms of durability.
Robot successfully traversing path using bluetooth
Today we are starting or lockbox project by learning about power tools and navigating onshape.
These are the constraints/requirements for our Lock Box project.
This is the stamp sheet for the tool/box portion of the project.
This is the stamp sheet for the lock/cad portion of the project.
The table cuts wood primarily along the length of the wood (rip cut) It only cuts straight lines.
Safety requirements:
Wear safety glasses
Remove loose clothing
Remember to turn the vacuum on to clean the excess saw dust.
Never get your hand within 6 inches of the saw.
Wood that I cut using the Table Saw:
It removes material from the top of the material to perform these three functions:
1) It will reduce the thickness of your material
2) Makes the material a uniform thickness
3) Make your material smooth/nice
Note: It is a very loud tool
Safety: Wear ear and eye protection, unplug when finished, don't put fingers near the opening, attach the vacuum before use, and don't put any wood with screws or metal into the planer.
Wood that I cut using the planer:
It cuts across the length of the wood. This is called a cross cut, and it can also cut at angles.
Safety:
Wear safety glasses
Firmly secure the material with your hand outside of the hand placement line and up against the fence
Vacuum after use
Unplug the saw
Reduce exposure to blade
Don't touch or manually move the blade guard
Plug in the saw with the cord across the body.
Wood that I cut using the miter saw:
Week 1 Onshape Progress Documentation
This course taught me how to navigate on-shape and help me learn it's insides and outs.
In this lesson so far, I have learned how to create a sketch and edit it.
This is my in progress sketch.
This tool cuts biscuit shaped holes on your material so that you can assemble your parts to be both.
1) Perfectly Aligned
2) Sturdy
Once you biscuit, you glue your parts together creating what is called a "glue up".
Safety rules: Wear safety glasses, make sure it is set for the appropriate size amount, make sure you set the height in the middle of the material, mark both sides of the material, camp a block in front of material each time, Don't put your fingers near the blade when it is plugged in, and don't assume the blade will come out of the material.
VCARVE PRO is used to develop simple designs for cutting/engraving.
Onshape files are used for more complex designs
Shopbot software actually controls the machine and runs the CAD files.
Safety tips: Run the dust collector, vacuum after use, wear ear protection, wear safety goggles, secure your material (with screws or clamps), and design around your screws. Don't leave the CNC while it is running, and don't go near the gantry while it is running.
Used to smooth out surfaces and get rid of jagged edges
Safety rules: Wear safety glasses, keep your sander moving at all times, be careful not to place sander on your skin. Don't operate the sander without asking the teacher, don't touch the sand paper while the sander is operational, and put the sander on surfaces that can be damaged by the sander.
The RFID Arduino lock works with an RFID sensor that is paired to an Arduino/circuit using the SPI interface. The RFID transmits a signal on a specific frequency to the card reader/tag. If the signal aligns with the input in the Arduino with the tags, the motor/servo will unlock and whatever is attached to it will be unlocked. This lock is secure because it cannot be picked unless there is a forged frequency, and it has much easier access than normal locks. I think it would be feasible to make in class because the sensor and frequency would be easy to recreate. Yes, it would meet the constraints, because it has components that we have used before and I could make the parts using CAD.
The padlock works because it has many pins that align with a certain key. The 6th pin sits within a groove, so it prevents the plug from being pulled out. Once the correct key is inserted, we can turn the plug and the padlock will become unlocked. If the key is incorrect, the pins will not align with the grooves and it will not allow you to turn it. This is possible to do in class, but it may be difficult because of the complexity of the key concept, so I don't think I'll consider this for one I'll try to do. It actually does meet the constraints as long as I make the parts in CAD and print them.
the Keypad Arduino lock works with a wired keypad connected to an arduino and an LCD screen where the numbers you input as your code show up. This lock is ran by program code that commands the lock what to do, and in the program code, you make a certain digit combination that unlocks the lock using an if then statement. Then, you compile and upload the code, and the commands are input into the arduino. There is a servo that is connected to a bolt that unlatches once the correct code is entered. There is also a little button that is connected to the circuit in case you need to unlock it from a distance, and that can be attached to keys. this one would be feasible if we by a chance we had a keypad, but all of the other components we definitely have used. This would meet the constraints because we've used all of the components before besides the keypad and it is an electronical lock.
The combo lock works by turning a combination of numbers using 3 cams. The back plate of the lock holds the cams, the turn axles, the springs, and the washers. they are all squished together and each cam is attached to the dial, in a specific numeric order. that's how when you turn the nob back and forth it switches cams. Once all the nobs are rotated to the same place, you can push the latch in and it will unlock. It is definitely feasible to o in class because this is the type of lock we did as a class example. It does meet the constraints, because it is a mechanical lock, it contains three designed parts, it can be made in CAD, etc.
Wood staining
Wear gloves, always stain over a drop cloth, put a small amount of stain on your rag, use a cotton cloth to apply stain, don't mix stains, don't leave staining materials out, don't leave stain rags out, and don't waste gloves
RFID lock
The RFID lock above is an electronic lock with a bolt that runs on code and relies on a sensor to unlock it. If the sensor's signal aligns with the input signal in the Arduino, the motor/servo will unlock and whatever is attached to it will be unlocked. This lock includes components such as a servo, a battery, an Arduino, wires, and a generic bolt.
RFID Lock Diagram and Components/Materials
Materials: Arduino Uno, battery, Servo + Servo horn, door bolt, wires, sensor pad, and RFID sensor
This is a video of me explaining how combo lock's components/parts and how they contribute to the functionality of the lock. For example, one part called the actuator is used to unlock and lock the bolt by inserting it into the rotors when they are aligned and turning the handle it is attached to. When assembling this lock, I had to be extremely careful and attentive to detail in order to ensure it functioned properly. If even one part is not assembled correctly, the entire mechanism can be negatively affected. I am satisfied with the end result and functionality of my lock.
Used shapes such as lines, circles, rectangles, arcs, points, squares and used constraints such as coincident, tangent, parallel, vertical, equal, perpendicular, and midpoint to create these models.
I created these parts by creating cad models using Onshape and its tools. I precisely measured each line and component of the cad model to ensure exactly accurate measurements.
Today I began creating the prototype for the bolt of my lock, and after I have completed this, I am going to put the design in tinkercad and 3D print it. I will use a dowel as the bolt inside the bolt body made of cardboard.
Create your file in Onshape
Right-click on the file (or sketch) and click export to DXF
Login to glowforge (create your account if needed)
Click create new
Click upload
Select your file
For cardboard select 1/2" corrugated cardboard
Day 2 prototype progress
Today I finished my bolt body and all i need to do for that part is to add the bolt itself to make it functional. Then, i started my circuit and attached my servo and what I need to do is connect the RFID sensors.
This is a shape I made using glowforge, and these are the steps I took in order to make it.
Create your file in Onshape.
Right click on the file (or sketch) and click export to DXF.
Open the Inkscape software.
Open your file in Inkscape.
Save your file to another file name (SVG filetype).
Log in to glowforge (create your account if needed).
Click create new.
Click upload.
Select your file.
For material select 1/8" corrugated cardboard.
Underproof grade cut, speed should be set to 440.
Make sure your drawing is on top of the material (within the limits of the material).
Click print.
Push the blinking button on the glowforge.
Monitor the glowforge for the duration of the cut for fire.
Remove your material with cuts.
This is the final prototype for my RFID sensor lock, and the presentation is below.
Lock prototype progress day 2
This is the 3d tinkercad design of my bolt that I implemented in my prototype and final lock.
Lock prototype progress day 3
This is the almost functioning cardboard prototype of my lock before I attached the servo to the bolt and added the 3D printed loop to the top of the box.
Lock prototype progress day 4
After I finished my cardboard prototype, I was approved to move on to the final lock using all digitally fabricated components, and this was my in progress laser-cut wooden lock enclosure.
Lock prototype progress day 5
I finished the construction of my lock enclosure and made it fully functional and now all I have to do is put it in my box and put my loop on under the lid of the box.
Lock prototype progress day 6
This is my final lock and enclosure inside of my box. I added my switch and attached the loop of the bolt underneath the lid and it is fully functional
Final Box Lock Video Presentation
We are working on a machine learning project and have engaged in research to help us better understand the concepts. We have learned about the ins and outs of the python program. with the help of Georgia Tech Professor Pascal Van Hentenryck. Personally, I researched topics such as object detection using computer vision and improving/optimizing a machine learning model. Here are my two posters:
Machine learning is a major branch of artificial intelligence that relies on a machine to imitate human behavior or perform tasks. Machine learning is used in many forms and is a very important tool that is extensively used to solve problems. Types of machine learning include supervised, unsupervised, and reinforcement models. The goal of my machine learning model is object recognition, but more specifically it is trained to recognize toy forms of transportation. The forms of toy transportation I have chosen for my model to recognize include a Ferrari, a Tonka tumbler, a helicopter, and a Packard car, and the four items are included below.
Ferrari
Tonka Tumbler
Helicopter
Packard
Per each object, I took about 200 48x48 small low-resolution pictures in a grayscale format using the Pycharm software to collect my data. The images were then loaded into a Google Drive data folder titled "XanderData" and accessed in my Google Collaboratory model. The examples of my objects in the low-resolution grayscale format are included below.
Ferrari in the grayscale format:
Tonka in the grayscale format:
Helicopter in the grayscale format:
Packard in the grayscale format:
Model Link: https://colab.research.google.com/drive/1QntH3tstLh3ehzDREYExgrfQ5YtK_toX?usp=sharing
My model is an object recognition model that is a supervised form of machine learning, and it is specifically trained to recognize four objects that are all toy forms of transportation. These objects include a Ferrari, a Tonka tumbler, a helicopter, and a Packard. I took the images for the data in my model in grayscale and low-resolution format using the program pycharm. We created this model based on the many principles we have learned over the course of the machine learning unit with Professor Pascal Van Hentenryck. In order to make the model, we imported multiple modules and data sets that are essential to commands of object recognition models such as Keras, Pathlib, TensorFlow, etc. Then, I connected the model to google drive where my data set is that contains the grayscale images of my objects. I essentially categorized the model, loaded the imported data sets, conducted the training for my data, and finally tested the model with the testing data, which resulted in 100% accuracy for recognizing the objects.
Above is the section of code that includes the model layers and model summary. This block of code essentially activates the model layers and establishes the inputs and outputs. The first layer listed in the code starts off with "layer = layer.Dense". This establishes this layer as a dense input layer, and as you can see further in the line of code, it activates the layer as a sigmoid function. The second layer on the third line of the block is established as a dense output layer that has a softmax activation function with a value of 6. The model summary at the end of the block sorts the layers and their order in the model. It also presents useful information such as the parameters of the layers.
These accurately labeled images essentially represent when the model got the predictions correct in relation to the true image.
After hundreds of trials of me executing the instruction, I never once had a mislabeled image. I suppose a couple of reasons for this could be that I took clear photos when I collected my data and had the correct code. I also made sure to double-check the training and testing data accuracy and it turns out I did in fact have 100 percent accuracy for both.
Here is my functioning neopixel strip circuit that we made together in class today. I used an arduino, a breadboard, wires, an led strip, and a target switch. I coded it to when the target is pressed, it resets the directional activation of the lights.