Ardunio

3/15/23

For my Arduino Assignment, I decided to go further into what we learned during class. Because this was my first time ever using a circuit as well as C++, and we were working in pairs, I struggled to keep up during the group work in class. With this in mind, I thought it would be best for me to redo the basics, the Ultrasonic Sensor and the LED lights, and then build from there.

One invention that I wanted to make was a Smart Crosswalk that wouldn’t require a pedestrian to press a button when crossing the street. As someone who commutes 30 minutes everyday to class in the freezing temperatures in Boston, this would help me a lot because I wouldn’t have to take my hands out of my pocket to press the button for the traffic light to turn . In this situation an ultrasonic sensor could be place where the button would normally be and it would be able to sense if it someone was approaching the crosswalk.

Here are the materials I used to create this:

UNO R3 Controller Board, Breadboard, 9 Breadboard Jumper Wires, 3-330 Ohm Resistors, 3 LED (red, yellow, and green), and then finally an ultrasonic sensor.

Next, the circuit was designed in a diagram and then in real life.

Here is a wiring diagram to show how all of the components were connected.
Here is what all of the components connected together on the breadboard looked like in real life

In this part of the project, designing the circuit, I ran into a couple of difficulties.

The minor difficulty was that because the breadboard was so small, it was really hard to keep all of the components organized as well as stick the Jumper wires into the board.

The major difficulty was that my USB cord stopped working halfway through making the circuit. At first, the correct port was not showing up on my computer, then I realized that although the circuit was plugged into my computer, the controller board was not on. If I held the cord at a certain angle, it would work for a small moment but unfortunately, it wouldn’t work long enough for my code to run all of the way through. It was also really hard to hold the cord and take a picture of the circuit at the same time.

After making the circuit, my next task was to make the code using C++ and the Arduino terminal.

Here is the code that I created to accompany the circuit

Up until line 30, the code was the same as the example that we did in class. I wanted the circuit to light up a different LED depending on how close the person was to the ultrasonic sensor. The “Smart Stoplight” will turn green whenever someone is 20 cm or more away from the sensor, yellow whenever someone is between 10-20 cm away from the censor, and then finally red for when someone is less than 10 cm away from the censor.

For this code, I had to figure out how to add multiple LED’s as well as do conditional statements. Lucky for me, after playing with Arduino and C++ a bit, I learned that a lot of the tasks and commands used are somewhat similar to the other two coding languages that I know, MATLAB and Python.

If I were to revisit this project, I would add a wait time in between the transition of the colors. In a real life application, it would be really dangerous if traffic lights changed immediately without a warning depending on how fast the pedestrian was walking.

I was able to take a lot of inspiration from class as well as from websites to help me develop my Arduino. Here are the materials that I used:

How to Control Multiple LED’s

https://www.instructables.com/Controlling-Multiple-LEDs-With-an-Arduino-Uno/

Powerpoint on Ultrasonic Sensors (from class)