PHY-S-12-DOCUMENTATION

View the Project on GitHub tahafarhan1/PHY-S-12-DOCUMENTATION

1 August 2019

11: Final Project Process

by

Deciding on an idea

At the start of the program, I had had the idea of making a bluetooth robot that followed you around using an app on your phone. It was supposed to use a bluetooth module with multiple sensors and motors and was supposed to look like the video below.

However, it proved to be too complicated that by the midterm week I had totally given up on it. Then when when we were using electronic output devices in session 9 I had the idea of making a car for the final. It was going to use two DC motors, two laser cut wheels, and was only going to work when the light flashing on the light sensor exceeded a certain value.

Building the circuit

I had started building this circuit a couple of weeks ago in (session 9)[https://tahafarhan1.github.io/PHY-S-12-DOCUMENTATION/09/] but I had to make some changes to it to add a second DC motor. The MOSFET transistor remained as well as the photoresistor, and the 10k ohm resistor. The MOSFET was connected to the Anonlog pin 2 via the ground pin, the drain pin was connected to the two motor wires and the source was wired to the 5V connector on the Arduino Uno board. Both the wires had two wires so one was connected to the drain on the MOSFET and the others were connected to ground. The picture below shows the motors connected to the ground (in the red circle) and the other two wires (green circle) connected to the drain pin. My light sensor and resistor were connected to the Analog A4 pin and the Arduino board was powered by a standard portable charger available in the lab.

Connections

My breadboard looked like this after it was properly connected.

Breadboard

Writing the code

The code I used was fairly similar to the one I used is session 9. However, I made some minor changes to it like I changed the value the motors would start working at which was 450. I noticed at this setting the motors turned on even when I was not flashing a light at them. This was because of the lights in the room itself. When I pointed the flashlight at it, the value was coming to the mid 740s and with the indoor lights it was in the 400s and 500s. I changed the threshold value to 675 so that it would only turn on when the flashlight was pointed at it. Another change that I made was to ensure that the circuit stayed on for 5 seconds after I stopped pointing the flashlight at it and the car should keep going forward. I did this by adding a delay function inside the if/else loop instead of it being at the end. I also added code for the circuit to remain off if the value on the light sensor was over 450 and only to turn on if the value exceeds 675.

int photoPin = A4;
int photoValue = 0;
int motorPin = 2;
 
 void setup() {
  // initialize digital pin LED_BUILTIN as an output.
    Serial.begin(9600);
 pinMode(2,OUTPUT);
} 

// the loop function runs over and over again forever
void loop() 
{
  int photoValue = analogRead(photoPin);
  Serial.println(photoValue);
  if (photoValue > 675) { 
    photoValue = analogRead(photoPin);
    digitalWrite(2,HIGH);
    while (photoValue > 350) {photoValue = analogRead(photoPin);}
    
     delay(5000);}
  else {digitalWrite(2,LOW) ;}
  
}

Building the car

This in my opinion was the trickiest part in making my final project. I had multiple attempts at laser cutting and every time the chassis of the car came too small or it was too weak. The picture below is a screenshot of what was supposed to be the base on Fusion 360. It had 4 holes that were supposed to fit the sides which were meant to be glued in.

Base

The next picture is what the long side of the car was supposed to look like. I was going to cut two of these and the rectangle that is sticking out would fit into the base.

Board Traces

The picture below is the short side of the chassis and there were suppose to be two of these too. The rectangle sticking out was to fit in the base.

Board Traces

However, this was a failed attempt as it can be seen in the next picture. Everything there was supposed to be used in the project like the DC motor holders(that proved to be too weak) and the sides with holes for the wheels (that were too small and broke when I drilled a hole in them).

Fails

I ended up getting frustrated and I realized I was short of time so I took a big piece of cardboard and I cut the pieces out by hand. I drew on the shape of what it should be like and used the scroll saw to neatly cut it.

Scroll Saw

There was one side that was uneven so I used a boxcutter to straighten it out. I then used the hot glue gun to stick all the sides to the base and to each other. I used the drill to make two holes towards the bottom of the side where the wheels would go. I taped the DC motors to the base as well to avoid any problems later on when I put the breadboard in. I had a problem with the wheels at first because they were really small so I printed bigger wheels about 90 mm in diameter made of acrylic. This material was thicker so it provided more balance to the car. The car also had a balancing problem that it kept falling backwards when I turned it on. To fix this, I hot glued a dowel rod with two small wheels to the back so when the car leaned backwards the car would still go straight as the backwheels would add more support.

Dowell Rod

My final project looked like this after everything was attached and working.

Car

A video of my final project is available on the Finished Project page.

tags: