dora crosswalk!

for this week’s assignment, I struggled to come up with an idea for a few days, until I finally came up with the idea of creating some like this:

the idea was that it was instead a bathroom stall, and using an ultrasonic sensor, the light would either turn on or off, and I would use a side switch as a lock to determine if the light was red or green, occupied or empty. To learn how to use the ultrasonic sensor, I used the Sparkfun Arduino guidebook where they give many different examples and explanations on how to use different items in the kit, as well as a code to use the ultrasonic sensor.  For the coding of the ultrasonic sensor, the most difficult part was getting the sensor to then return the distance it was measuring and use it in the code to determine the color of the light.

In trying to execute the idea, I thought that the switch would either turn on or off, so I couldn’t use it to change color, but instead, I could use the ultrasonic sensor to change the color. I then reconsidered and thought about using the ultrasonic sensor to determine the color of the lights to create a cross-walk where the distance of the pedestrian decided both the color of the light for them to cross and the color of the light for cars to pass by. To incorporate a button I wanted to make it so that if Dora reached the road but didn’t want to cross she could switch the color of the lights, make hers red and the light for the cars green, but I couldn’t get the code to work. I tried using two different if statements which I realized wouldn’t work and instead, I tried using && but what would happen is the lights would be off and turn on with the button, and once on when Dora was close, instead of having a green light and cars a red light they would both quickly flash red and green.

In the end, although it wasn’t what I wanted the button to be used for, I added it as headlights to the car, which wasn’t difficult besides having to be careful with the wires and making sure they were long enough.

In the future I think the more I understand how to code within Arduino, the more I will be able to accomplish.

Here are a few clips of Dora crossing the road!

https://youtube.com/shorts/mXF2TBsvka4

Leave a Reply