The IR sensor’s function in our project was to detect when the hat is worn. Initially, it was implemented alone on a breadboard for testing. This particular sensor had a supply voltage of 4.5V-5.5V, so it could take power directly from the Arduino board. The sensor test program and serial monitor in the Arduino IDE showed the output values ranging from 0-1023, which indicated the detected distance.
Initially, we had the color sensor connected directly to the 5V port of the Arduino board. Once we realized that the color sensor has a max voltage setting of 3.8V, a voltage divider was implemented within the circuit to step down the 5V from the Arduino. The two resistors in voltage divider in series were a 220 Ohm resistor and a 330 Ohm resistor.
The 5V from the Arduino was inputted into the power line of the breadboard. From there, the voltage divider stepped it down for the devices that required it. The last item we needed to implement was a piezo buzzer, which was very simple in nature (when pin is high, buzz; when pin is low, stop buzzing). Delays and duty cycles are cleverly used to trick the piezo buzzer in playing decipherable simple music. A short tune of the Harry Potter theme music was found and implemented into our code.
Below are some of the pictures of to give a overview of how everything was wired up: