Components and Coding

The circuit board was designed on PCB which allowed us to customize the positioning of every component and place the connecting tracks where needed, this helped to keep the circuit very neat and made the process of wiring the components much simpler. Our circuit board is made up of, 4 LED’s with 470 Ohm resistors, a push-to-make switch and an LDR, both with 16 K Ohm resistors, a Mosfet and a loudspeaker.
The 3D model was produced using solid works and then sent on to the rapid prototyping machine. The model itself is the general shape of an Apple IPhone, only slightly larger to accommodate all phones including HTC’s which we found to have the largest screen sizes. The model was made solid, and then shelled out to save on material costs. The walls throughout are all 2 mm thick which was found to be thin enough to keep the cost down, but still thick enough that it had good durability. Each component has its own space in the model to be embedded in, so that they, and the wires, are kept hidden away. There is a small curved section cut out of the wall on one side where the phone sits, this allows the user to easily pick their phone out of the dock. Every corner/edge of the model was filleted to make sure that any chance of scratching the screen or covers of the phone was avoided.

The Coding for the project is as follows:

#include
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay (clock=20000000)
#define WHITE_LED1 PIN_C0
#define WHITE_LED2 PIN_C2
#define WHITE_LED3 PIN_C4
#define WHITE_LED4 PIN_C1
#define PUSH_BUTTON PIN_C3
#define LOUDSPEAKER PIN_C5
//#define LDR PIN_A1
void main()
{
int reading;
while(true)
{
//program waits at this line until the button is pressed
while(input(PIN_C3));
Setup_adc_ports (RA0_RA1_RA3_Analog);
Setup_adc (ADC_CLOCK_INTERNAL);
Set_adc_channel (1);
reading = read_adc();
if (reading< (50))
{
Output_LOW(LOUDSPEAKER);
Output_LOW(WHITE_LED1);
Output_LOW(WHITE_LED2);
Output_LOW(WHITE_LED3);
Output_LOW (WHITE_LED4);
Delay_ms(5);
Output_HIGH(LOUDSPEAKER);
Output_HIGH(WHITE_LED1);
Output_HIGH(WHITE_LED2);
Output_HIGH(WHITE_LED3);
Output_HIGH(WHITE_LED4);
Delay_ms(5);
Output_LOW(LOUDSPEAKER);
Output_LOW(WHITE_LED1);
Output_LOW(WHITE_LED2);
Output_LOW(WHITE_LED3);
Output_LOW(WHITE_LED4);
Delay_ms(5);
Output_HIGH(LOUDSPEAKER);
Output_HIGH(WHITE_LED1);
Output_HIGH(WHITE_LED2);
Output_HIGH(WHITE_LED3);
Output_HIGH(WHITE_LED4);
Delay_ms(5);
Output_LOW(LOUDSPEAKER);
Output_LOW(WHITE_LED1);
Output_LOW(WHITE_LED2);
Output_LOW(WHITE_LED3);
Output_LOW(WHITE_LED4);
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: