This code was intended for an ATMega328p and was coded using Atmel Studio 7. The purpose of the code is to detect if the microcontroller gets a shock and if it does send a signal to the buzzer to let the user know the won. We accomplished this by creating a while-true loop that goes on continuously until it detects a signal from the shock sensor, that is set as an input in PIN 5 of Port B, if it detects a shock it will generate a random integer between 0 and 5. If the integer that was generated is the same as the one specified in the code, in this case a 3, it will activate and deactivate the buzzer, set as an output on PIN 5 of Port C, letting the user know if they have won or not.
The concept of this project is a carnival arm that can set off a buzzer if a user can drop a ball into a cup. The project uses two Atmega328PB boards. One board has a servo motor that that works by connecting it to ground, 5v, and to PB1. The second board is connected to a passive buzzer at 5v, ground, and PD1 as well as a shock sensor at 5v, ground and PB2.
We performed the project with the intent of applying some of what was learned throughout the semester. It was originally conceived with the idea of using a servo motor and sensors, at which point it was only a question of how to use them in a practical way. We decided on a carnival game (of sorts) that involves placing a ball on a rotating slide and aiming it toward an opening to a buzzer sensor/shock sensor combination. If the player hits the buzzer, a random number generator determines whether the buzzer goes off (win) or does nothing (loss). In other words, the game relies on a combination of skill and chance. In true carnival game fashion, the player gets three chances to to make the buzzer go off. We used two computers, two microcontrollers, two breadboards, a shock sensor, a passive buzzer, a servo motor, foam golf balls, and a variety of household items