Define the problem
Goals:
To get the Optical Light to blink for 10 seconds
To get optical sensor to differentiate between soccer ball and other objects
To get code to continuously loop without stopping.
To get the Optical Light to blink for 10 seconds
To get optical sensor to differentiate between soccer ball and other objects
To get code to continuously loop without stopping.
Generate concepts
Develop solution
When we started building, we knew the design had to include a battery, brain, some type of sensor, and a soccer goal. To take up the least amount of space possible, we stacked the battery on top of the brain so we had room to build. To create a goal, we used three metal panels and a thin piece of metal to catch the ball at the back of the goal. We tried out an optical sensor first, but after trial and error we ended up attaching a distance sensor to the back of the goal to sense the ball when it enters. The optical sensor we originally used was left attached to the top of the goal and blinked when a goal was made. For the code, we knew we needed to make sure the sensor could differentiate from the ball and whatever else entered the goal. We also needed the optical sensor to blink for ten seconds when a goal was made. So, we used a closed loop that responded to feedback. We used and if then statement and the criteria was if the distance sensor detected an object 1 mm away. This was so it would detect the ball when it was fully in the goal. If the criteria was met, then run optical light blink code ten times. For the optical light blink code, the light turned on for half a second and off for half a second. So, when repeated ten time this lasts for ten seconds. Additionally, if the criteria was met “object detected” would be printed on the brain. This as extra assurance to make sure the sensor was working properly. All of the code was put in a forever loop so it repeats allowing you to make more than one goal.
Construct and test prototype
Evaluate solution
The first problem we ran into was the code. We had a working code but we weren’t sure how to repeat it more than once without restarting it. At first, we were using a variable to get the light to blink for ten seconds but once the code ran through it wouldn’t repeat again. We tried while loops and forever loops but nothing worked. So, we switched the code to an if then statement and repeated the light blink code 10 times. We put the entire code in a forever loop and finally got the code to work. It now will run continuously and respond if the criteria is met every time. The next problem we ran into had to do with our optical sensor. Our ball was green, and it could sense the ball but only if it was almost touching the sensor. We tried moving the location of the sensor but that didn’t work either. We ended up switching to using a distance sensor which responded much better to our design. The final problem we ran into was that the distance sensor was picking up objects too far away from our design. To solve this problem, we put a white piece of paper in front of all the other objects it was detecting.
Present a solution
Conclusion
I learned how to code a closed loop program which I used to make the optical light blink based on feedback from the optical sensor. I also learned how to make a variable and call the function in a code. The most surprising part of the project was the hardware. Trying to find the distance at which the distance sensor could see our ball was difficult because we weren’t sure what objects it was picking up. It was also hard to see how far away our optical sensor could see since we weren’t sure if our code was wrong or if it couldn’t detect the color we were using. Later we found our after much trial and error that the sensor couldn’t see very far away. One thing that could be added to the design problem is an opposing team’s goal. Another thing that could be added is a light that blinks however many goals that are scored.