Two-Lock Safe: Locking Code

Servo Code:

Two Lock Safe – Overview
#include <avr/io.h> #include <util/delay.h> //Function Prototypes void lock(); void unlock(); void init_PWM(); void setDDR(int b, int c, int d); void lock(){ init_PWM(); //assume lock = -90 degrees = 1 ms pulse OCR1A = 0x946E; _delay_ms(10000); setDDR(0,0,0); } void unlock(){ init_PWM(); //assume unlock = 0 degrees = 1.5 ms pulse OCR1A = 0x9086; _delay_ms(10000); setDDR(0,0,0); } void init_PWM(){ //set data direction on port b, other ports are off setDDR(0xFF, 0, 0); //set waveform generation mode (mode #14 on datasheet: fast pwm) TCCR1A |= 1<<WGM11 | 0<<WGM10; TCCR1B |= 1<<WGM12 | 1<<WGM13; //set output mode (inverted, starts low & switches to high on compare match) TCCR1A |= 1<<COM1A1 | 1<<COM1A0; //set prescaler (clk/1, no prescaler) //001 -> clk/1 //010 -> clk/8 TCCR1B |= 0<<CS12 | 1<<CS11 |0<<CS10; //set period (20,000 counts per second -> 20ms period) ICR1 |= 0x9C3E; } void setDDR(int b, int c, int d){ DDRB = b; DDRC = c; DDRD = d; } int main(void) { while(1){ lock(); unlock(); } }

Code used to program the microcontroller to set the servo to lock and unlock.

Two-Lock Safe Schematics

The transistor is needed to control when the solenoid retracts from lock into unlock. 12 Volt 1.25 A power supply required because the specific solenoid used operates with 12 Volt 1 A. The 12 key keypad uses up seven pins and connected to PortD. DDRD was set to receive input from 12 key keypad and outputs on pin connected to transistor and for servo rotations, PortA and Port B set to output.

Dragon Bank Overview

We are making a piggy bank that will keep track of how much money is inside the bank. The general idea is to make a cardboard coin sorter and set up some lights with photo sensors to track how far the coins have gone. If a coin makes it to the end, we are assuming it is a quarter but half dollars and dollar coins will be able to fit as well, to not clog the ramp.

Laser Harp – Schematic

The fundamental principle behind the laser harp is that a laser shines on a photoresistor making the resistance in the photoresistor close to 0 ohm, and when the a finger is blocking the laser from making contact with the photoresistor, the resistance goes to almost 200k ohm. By using the photoresistors as pulldown resistors in parallel with another set of resistors, the voltage divider rule can be applied to determine what the voltage values will be when the laser is broken. High and low voltages can be sent to the Atmega328p to determine when to play a note.

Continue reading Laser Harp – Schematic

Laser Harp – The Big Picture

For our project, we decided to do something that would apply everything we had previously learned in class, as well as something that could potentially make an impact in society (as a big picture).

We chose to do a laser harp as our final project.

Currently, there are companies that manufacture top-notch laser harps, which price their products at a hefty price of 700$ to 2000$. This was our attempt at building a budget friendly laser harp, that would potentially make an impact of 100$ or less to the consumer’s pocket. We successfully built the laser harp with less than 100$ spent on materials.

This could potentially impact the market of laser harps.

Not only this, but the laser harp can serve as a budget friendly way to learn how to play an instrument, as well as helping the consumer recognize and learn different musical notes. The good thing about the harp is that almost anyone can play it. This can come to benefit of children or adults with motor skills difficulties. It could potentially help them if learning how to play an instrument or music, is something they want. To take this concept even further, the harp can be used in conjunction with music theory, to teach mathematics and science to people with intellectual disabilities.

Overall, the big picture of the “budget-friendly” laser harp is to give consumers more accessibility to laser harps, as well as helping and educating people who suffer from intellectual disabilities and/or motor skills.

Electronic Safe: Code Snippet

void StoreKey(char *str)

{

ee_up = 0x00;

ee_low = ee_up + 5;

while (*str)

{

bit = *str++;

EEPROM_Write();

ee_up =ee_up+10; //test

ee_low = ee_up+5;

}

lastaddress = ee_up;

}



void GetKey(void)

{

ee_up = 0x00;

ee_low = ee_up +5;

while (ee_up != lastaddress)

{

EEPROM_Read();

UART_Put();

ee_up = ee_up +10;

ee_low = ee_up +5;

}

}

The code above is used to store a variable length PIN in EEPROM and retrieve it when needed. It starts at address 0x00 and increments by 10 for every successful digit. Once the PIN is stored it saves the last used address into a variable so the GetKey() function knows when to stop.

 

Electronic Safe: Big Picture

Electronic Safe:

The final project is an electronic safe that requires you enter the correct pin to open the safe. To create this safe a shoe box was used as an exterior housing, as well as a variety of components to perform the safe functions: a matrix style number pad, an LCD module, and a servo motor. The MCU to control the safe is an ATmega328p that was programed using a Windows 10 PC and Atmel Studio 7. The safe was unable to be completed, as the matrix style number pad was unable to be interpreted accurately; however, the rest of the safe functioned as predicted.

Laser Harp-Code Snippet

This snippet of code reads the pins on PORTD. If a pin on PORTD is high, “data” will be larger than 0 and will get stuck in the while loop until the pins on PORTD are low again.¬† Before entering the loop, global interrupts are enabled which allows the interrupt that generates the tone to be called. Then after all pins on PORTD are low, global interrupts are disabled and the program continues. This is used so that a constant tone will be played for however long a laser is blocked.