Carnival Arm Schematics Group 6

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.

LED Candle Light Show

For our teams final project, four LED candles with ATmega328P(B) boards are programmed to display a creative light show. Each candle is identically hand-built and connected to an ATmega328P or ATmega328PB microcontroller. These four devices are all then connected to a single ATmega328PB that serves as the master controller. The master board is programmed with all of the light routines and signals the individual boards to turn the LEDs on or off at different brightnesses. In order for the master controller to communicate with the slave boards, the I2C interface is utilized. The purpose of this project is to develop a simple prototype for a future, larger candlelight display that can be wirelessly programmed to display more complex light shows.

Infrared Controlled Wah-Wah – Big Picture

The goal of this project was to build and program a wah-wah guitar effect pedal that is controlled through an infrared sensor to detect hand motion and vary the frequency of a guitar signal based on distance from the sensor.  Traditional wah-wah pedals are controlled via a potentiometer that varies the frequency response of the guitar creating a vocal wah wah sound effect. For this project the potentiometer was replaced with an LDR ( light dependent resistor), which varies resistance based on the amount of light detected.  The LDR was coupled to an LED with heat-shrink tubing to directly vary the amount of resistance based on the brightness of the LED. The LED is controlled with the atmega328pb microcontroller using ADC and PWM. The project was successful and resulted in an effective wah-wah guitar effect that is controlled through hand  movement. Control through the distance sensor allows for unique and expressive sounds based on the motion that the IR sensor detects. The sounds range from smooth crescendoing wah, to a fast stuttering effect when the hand is waved in successive motion over the sensor.

Sleep Timer

The initial goal of this project was to build a standard Alarm Clock. To do this we would have to interface with an RTC chip using the I2C interface. A RTC Chip is a real time clock that can retain time data even after the power main power has been cycled. This function is performed through the use of a small battery. Unfortunately, we were never able to find the battery needed to operate this chip. This means that we would have to approach our project differently.

This is when we came up with the idea for a sleep timer. The user could set the desired amount of time, default 8 hours, and after the time ran out the alarm would sound. After the alarm was sounded, the user could choose to snooze or let the alarm run. If the alarm runs to completion, the LCD is updated with a “report” of the time slept, including snoozes. Below is a flowchart of the program:

Sleep Timer Code

In a portion of our code we needed to look for a button press to change a variable. To do this we used a while loop that incremented a counter when the button was not pressed and changed the value when the button was pressed. This allowed for the user to edit the value for a set amount of time and then move on to the next portion of the code. Below is the code

 

counter = 0;
LCDWriteString(“SET MINUTES”);
LCDWriteIntXY(1, 2, minutes, 2);

//Get minutes
while(counter < 10)
{
_delay_ms(500);
LCDClear();

int temp = PIND & 0x01;
if (temp == 0x00)
{
counter += 1;
}
else
{
minutes += 1;
if (minutes > 59)
{
minutes = 0;
}
}

LCDWriteString(“SET MINUTES”);
LCDWriteIntXY(1, 2, minutes, 2);

}

Smart House – Big Picture

The goal of this project was to create a smart house that could be controlled using a smartphone, which was achieved using Assembly, C, and Arduino Languages. In this project both the Atmega328PB and Arduino Uno R3 boards were used in conjunction. This was done to show how different languages can be used alongside each other by connecting inputs and outputs. The Arduino was used to connect our circuit to an app via Bluetooth to control the lights and door lock of the house. The ATmega328PB board was used along with an LCD to display when the door was locked or unlocked.

Infrared Controlled Wah-Wah – Code Snippet

The programming of the microcontroller was accomplished using Atmel studio 7 on Windows 10.  The goal of converting the analog voltage produced by the Sharp IR sensor to a digital signal was accomplished using the ADC of the microcontroller. The ADC was setup in an ADC initializing function, ADCinit. PC5 was selected as the input for the ADC by setting the MUX0 and MUX2 to 1. The ADCSRA register was set up to enable the ADC, enable auto trigger, enable interrupts and set the prescaler to 64. Global interrupts were enabled in this function using the sei instruction. The output voltage of the sharp IR sensor was found to have a range of 0 to 3 volts depending on the distance. The ADC voltage reference was set to 3.3 volts to more closely match the output of the IR sensor as opposed to the 5 volt default. This was accomplished using AREF as the voltage reference by connecting the 3.3 volt output of the microcontroller to AREF pin with a jumper wire. The LED brightness was controlled with PWM. PWM was set up in the PWMinit function. The clock was set up with no prescaler and using CTC mode. In this mode the OCR1A acts as the top value of the counter while the OCR1B is the value to be compared to. Interrupt service routines were used to change the duty cycle based on the ADC value passed into the duty variable and then by setting OCR1B compare value to duty.  The result of the program was a smooth fluctuation in the brightness of the LED based on the distance of a hand or object from the sensor.

The Wah circuit was combined with the microcontroller by inserting the LED and LDR into a heat-shrink tube in order to have the light passed to the LDR directly related to the LED without outside light interference. The resulting behavior of the LED based on hand position can be observed in the video above.

Bike Odometer & Speedometer – Code

We wrote code for the project for both the Atmel Xplained board in Atmel Studio and an Arduino Uno (has the same processor as the Xplained Board). Originally, the Arduino was used just for proof-of-concept testing and for a user friendly testing platform to iron out any unforeseen kinks with the program flow or mathematical computations. Once that was completed, development switched to Atmel Xplained board. The end functionality of the code written for both boards is fairly comparable except for the speedometer module. A critical component to the speed calculation is the elapsed time between the voltage drops of the Hall effect sensor. For the Arduino Uno this was no problem as an external clock source separate from the Atmega 328p is integrated into the board. In addition to build in functions that make interfacing with the clock extremely easy. On the other hand, the Atmel Xplained board has no external clock source. So all timing had to be done utilizing timers based off the CPU clock speed. Overall, this created a more complex piece of code with worse functionality.

 

Fun Box #3

In general we learned a lot in this class. The overall ability to use the AT Mega 328PB allowed us to understand another embedded system of an Arduino. This ability to focus on what is needed, as we already learned how to effectively program one board, helped us quickly and effectively solve the other board. Not only did we do one board, but we did two Arduino board integration with the AT Mega to solve the problem we had at hand. A more powerful micro-controller was needed as we ran out of IO pins on the Arduino, but the foundation would be the same if we switched to a PI or used a more detailed AT mega board with larger IO Pins. The foundation of Assembly in this source built the code awareness to understand libraries and even begin able to make our own on our computer to effectively create a unique system or objects.

The code used in the Arduino outlet was not overly complicated as the foundations were similar except with a different IDE and the C programming was easier to use. The ATmega was used as a motor controlled allowing for a simple call then react(slave action) operation for us to effectively use a motor to cool an area that was above the ambient conditions in the surrounding area per the DHT temperature sensor.

Lastly, the project gave us the ability to start from scratch of an embedded system. We created the functions of needing a temperature sensor/motor to cool, LCD to play a game with buttons, and a ultrasonic sensor to say if something was nearby. We used our resources to determine we needed a micro-controller as all of the sensors were able to have built or easily updated libraries in Arduino. The functionality was built like the rest of our projects as we integrated with the AT mega as a motor controller to help finalize our last task and communicate through a simple slave operation. More detailed communication of serial or I2C may have been optimal, but for our functionality and timing requirements, it was not needed.