Josephine S.

Hi! My name is Josephine and I’m a rising sophomore at the Ramaz Upper School. My starter project is the Simon Says game by Sparkfun. I chose this starter project because I have never soldered before, so this project gave me many opportunities to practice my soldering skills. My main project is the RC Robot Tank. I chose this project because I was excited to work with Arduino in addition to doing mechanical engineering for my first time.

Engineer

Josephine S

Area of Interest

Biology, Electrical Engineering

School

Ramaz Upper School

Grade

Incoming Sophomore

Final Milestone

My main project is the RC Robot Tank, a tank that drives and is controlled by a PS2 controller. There were many steps in the process of making this tank. First, I had to assemble the chassis and motors, which was a challenge because the instructions were in Japanese. Second, I created a circuit with the motor, battery, Arduino, and motor shield so that the tank could drive. Next, I connected the PS2 controller to the Arduino and wrote code so that the PS2 buttons move the tank in certain directions. Finally, I added my modification, a 3D printed case to hold the battery and attached all my components to the chassis. I learned many skills throughout this process. I learned how to solder for the first time, which I used to fix my faulty PS2 controller and attach jumper wires to my motor. I learned what an Arduino motor shield is and how to use it, as well as what the different pins in an Arduino are for and how to create a circuit with them. Although I have coded in Arduino before, my coding skills improved a lot with this project. I gained experience reading other people’s code and understanding how to apply it to my own project. I also learned how to import new libraries, like the PS2X library I used for my project, and used many functions I had never used before, such as to detect whether buttons have been pressed on my controller. I gained wiring skills when I connected the PS2 controller to the Arduino, learning the function of each port and pin. I also used tools I had never used before, like the Dremel. To print my modification, I learned how to use Autodesk Fusion 360. I faced many challenges in this process. The hardest part was connecting the Arduino to the PS2 controller because there were so many different components involved: the code, the wiring, and the PS2 controller. I fixed the faulty PS2 controller and checked my wiring in my circuit. However, there were still issues with coding for movement of the tank. At that point, I realized that there was interference from another student’s PS2 controller, so my controller was connecting to his Arduino instead of my own. We had to coordinate turning on our controllers to make sure they connected to the right receiver. Additionally, I realized that I had the wires from my PS2 receiver connected to pins in the Arduino that were used for the motor movement. I was calling the pins twice for two different functions, so the code wasn’t working. To fix this, I switched the pins that the receiver was connected to, and at that point the code worked.
3d-printed-battery-holder-screenshot
My modification is a 3D printed battery case that I am using to mount the battery pack on the tank. I was having trouble mounting all of the components (including the Arduino with the motor shield, the motor, the PS2 receiver, and the battery pack) on the relatively small chassis. To fix this, I decided to mount the battery vertically on the chassis in a 3D printed case. This was a challenge because I had very limited time to create the case, and I have never 3D printed anything before. However, I have some experience with 3D modeling which was helpful.

#include PS2X ps2x;

int error = 0;
byte type = 0;
byte vibrate = 0;

int speedA = 80; /*setting this up to change this value using analog write (values from 0-255)
so I can change it based on user input through the PS2 contoller. 80 is the default speed
once the motors start. There are 2 speed values, one for A and one for B*/
int speedB = 80;

int motornameA;
int motornameB;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(“Serial monitor initialized”);
//(clock, command, attention, data, pressure sensitivity enabled?, rumble enabled?)
error = ps2x.config_gamepad(4, 5, 6, 7, false, false);

if(error == 0){
Serial.println(“Found Controller, configured successful”);
}

else if(error == 1)
Serial.println(“No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips”);

else if(error == 2)
Serial.println(“Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips”);

else if(error == 3)
Serial.println(“Controller refusing to enter Pressures mode, may not support it. “);

type = ps2x.readType();
switch(type) {
case 0:
Serial.println(“Unknown Controller type”);
break;
case 1:
Serial.println(“DualShock Controller Found”);
break;
case 2:
Serial.println(“GuitarHero Controller Found”);
break;
}

//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin
Serial.println(“Channel A setup complete.”);

//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel A pin
pinMode(8, OUTPUT); //Initiates Brake Channel A pin
Serial.println(“Channel B setup complete.”);

Serial.println(“Setup finished”);
}

void loop() {
// put your main code here, to run repeatedly:
delay(100);
ps2x.read_gamepad();

//right side buttons if statements FOR MOTOR B

if(ps2x.ButtonPressed(PSB_GREEN)) //up
{
digitalWrite(13, HIGH); //Establishes forward (same as A backward) direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, speedB); //Spins the motor on Channel B at speed’s value
motornameB = 11;

digitalWrite(12, LOW); //Establishes backward (same as B forward) direction of Motor A
digitalWrite(9, LOW); //Disengage the Brake for Motor A
analogWrite(3, speedA); //Spins motor A at speed’s value
motornameA = 3;

}

else if(ps2x.ButtonPressed(PSB_RED)) //right
{
Serial.println(“red pressed”);
//move motor A
digitalWrite(12, HIGH); //Establishes forward (same as B backward) direction of Motor A
digitalWrite(9, LOW); //Disengage the Brake for Motor A
analogWrite(3, speedA); //Spins motor A at speed’s value
motornameA = 3;

//brake motor B
digitalWrite(8, HIGH); //Englage the brake for Motor B

}

else if(ps2x.ButtonPressed(PSB_PINK)) //left
{
Serial.println(“pink pressed”);
//move motor B
digitalWrite(13, LOW); //Establishes backward (same as A forward) direction of Motor B
digitalWrite(8, LOW); //Disengage the Brake for Motor B
analogWrite(11, speedB);
motornameB = 11;

//brake motor A
digitalWrite(9, HIGH); //Englage the brake for Motor A

}

else if(ps2x.ButtonPressed(PSB_BLUE)) //down
{
Serial.println(“blue pressed”);
digitalWrite(13, LOW); //Establishes backward (same as A forward) direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, speedB); //Spins the motor on Channel B at speed’s value
motornameB = 11;

digitalWrite(12, HIGH); //Establishes forward (same as B backward) direction of Motor A
digitalWrite(9, LOW); //Disengage the Brake for Motor A
analogWrite(3, speedA); //Spins motor A at speed’s value
motornameA = 3;
}

//middle buttons if statements

else if(ps2x.ButtonPressed(PSB_SELECT))
{
Serial.println(“select button pressed”);
//brake motor A
digitalWrite(9, HIGH); //Englage the brake for Motor A
//brake motor B
digitalWrite(8, HIGH); //Englage the brake for Motor B
}

//side buttons right if statements

else if(ps2x.ButtonPressed(PSB_R1))
{
Serial.println(“right side side upper button pressed”);
speedB = speedB + 10;
speedB = constrain(speedB, 0, 255);
Serial.print(“Speed B = “);
Serial.print(speedB);
Serial.println(” “);
speedA = speedA + 10;
speedA = constrain(speedA, 0, 255);
Serial.print(“Speed A = “);
Serial.print(speedA);
Serial.println(” “);

analogWrite(motornameB, speedB);
Serial.println(motornameB);
analogWrite(motornameA, speedA);
Serial.println(motornameA);
}

else if(ps2x.ButtonPressed(PSB_R2))
{
Serial.println(“right side side lower button pressed”);
speedB = speedB – 10;
speedB = constrain(speedB, 0, 255);
Serial.print(“Speed B = “);
Serial.print(speedB);
Serial.println(” “);
speedA = speedA – 10;
speedA = constrain(speedA, 0, 255);
Serial.print(“Speed A = “);
Serial.print(speedA);
Serial.println(” “);

analogWrite(motornameB, speedB);
Serial.println(motornameB);
analogWrite(motornameA, speedA);
Serial.println(motornameA);
}
}

Reflection

My experience at Bluestamp Engineering was extremely valuable and rewarding. When I started at Bluestamp, I wasn’t sure how interested I was in engineering or how much I would be able to achieve with little engineering experience. However, by the end of this program, I have learned so much about different areas of engineering, including mechanical engineering, electrical engineering, and programming. When we had guest speakers, I was interested to hear about how many options there are for careers in the engineering field.

At this program, I surprised myself with abilities to persevere, overcome challenges and problem solve creatively. I feel more confident about my engineering skills after this program because I was forced to figure out every step of my project on my own, with help from the instructors only if I was really stuck. Because of this, I gained the skills necessary to create more projects on my own later. I loved the feeling of creating something from nothing in engineering and I have gained so much from my two weeks at Bluestamp.

Second Milestone

My second milestone was connecting my PS2 controller to my Arduino and writing code so that the Arduino can detect the buttons being pressed on my PS2 controller. This involved several components, including wiring the PS2 receiver with the Arduino, fixing the poor quality PS2 controller that I had, and compiling code for each of the buttons on the controller. I learned what the different wires were for in the receiver and which I needed to use, but after assembling all the wiring the PS2 controller still wouldn’t connect. At first, I realized that there was a wiring issue where one of my wires wasn’t fully on the pin in the receiver, so it wasn’t working. However, even after I fixed that it still didn’t work. While I was working on this, the PS2 controller behaved erratically, randomly shutting off and not turning back on until you flipped the batteries around multiple times. Then I realized that this was the reason that the PS2 wasn’t connecting to the Arduino. At that point, I unscrewed the back of the PS2 controller and checked inside. The soldering on the board wasn’t good, so I fixed the soldering there. It still didn’t work, so I realized that a wire had come unattached inside and needed to be resoldered. Finally, after taking apart the controller three times and putting it back together, it interacted with the Arduino. Then, I started to work on the code for the Arduino. I installed the Arduino library PS2X, written by Bill Porter, and started with his example code. From there, I created my own code so that each time a button is pressed on the PS2 controller, it displays in Arduino’s serial monitor. There are lots of different functions in the PS2 library, including for pushing a button, holding a button down, or detecting with how much pressure the button is pushed. For my purposes, I only needed the ButtonPressed function. This was the most challenging part of building my project so far because of how much troubleshooting was involved. When I had issues, it was difficult to identify whether the problems were with the code, the faulty PS2 controller, or the wiring to the Arduino. Now that the PS2 controller is working with the Arduino, my next milestone will be to connect the tank and motor to the PS2 controller through the Arduino and assign buttons on the PS2 controller to different movements for the tank.

First Milestone

My first milestone was creating a circuit with the Arduino, motor shield, battery, and motor and running a simple code with the tank so that it moves. Once I connected all of these components and uploaded my code to the Arduino, the tank moved. There were many steps in this process. First, I soldered wires to my motors. Then, I used the wires to connect the motors to the A and B channels in my motor shield, which I connected to my Arduino. This was my first time using a motor shield, so I had to learn about that and how to use it. Other than that, this was fairly straightforward. The more challenging part of the process was connecting the battery to this circuit. At first, I was connecting a 5V portable battery to the circuit through the USB port in my Arduino. When that was connected, the tank moved, but fairly slowly, and one of the motors would only run in one direction. Originally, I thought that this was a problem with either the code or the motor, so I tested each section of the code to make sure that the motor would run in every direction. Individually, each motor would run each direction, but when the code was put together, it lagged in the same place as before. At that point, I realized that the issue was with the battery. There wasn’t enough current entering the motor through the Arduino when using the USB port, so I had to use the hub on the motor shield instead. Then I tried a 9V battery, but that didn’t work either because it didn’t have enough current. Finally, I found a 9.6V rechargeable battery pack that worked. It had enough current to power the Arduino and the motor, and enough voltage to make the tank drive much faster as well. Currently, I have a simple code on the Arduino that programs the tank to drive one direction for 3 seconds, break for 3 seconds, and then drive the other direction for 3 seconds. The code uses the digitalWrite() function to start the motor with the parameter HIGH and stop the motor with the parameter LOW. The code also uses the analogWrite() function to control the pwm level of the tank and how fast it goes. My next milestone is connecting the PS2 controller to the Arduino so that it controls the tank, and coding for the functions of its buttons.

Starter Project

For my starter project, I built the Simon Says game. This game has many components, including batteries, a microcontroller, a piezo buzzer, LED lights, a resistor, and switches. The microcontroller runs the game and lights up the LEDs in specific patterns. It also registers when you push a button and whether or not you were correct, and sends these signals to the LEDs to continue the game. The piezo buzzer controls the sounds of the game. All of the components of the game needed to be soldered together, and this was the first time I have soldered. One challenge I encountered was that after I assembled the game, it still didn’t work. After some troubleshooting, I realized the problem; one of the batteries wasn’t touching the battery clips, so it wasn’t powering the game. I used pliers to bend the battery clip inwards and fix this issue.

Leave a Comment

Start typing and press Enter to search

Bluestamp Engineering