Question: FROM THE GIVEN CODE BELOW, PLEASE PROVIDE THE SCHEMATIC OF THE FULL WORKING CIRCUIT IN PROTEUS 8 SOFTWARE. THIS IS A PARKING OCCUPANCY SYSTEM USING

FROM THE GIVEN CODE BELOW, PLEASE PROVIDE THE SCHEMATIC OF THE FULL WORKING CIRCUIT IN PROTEUS 8 SOFTWARE. THIS IS A PARKING OCCUPANCY SYSTEM USING LDR SENSOR, DC MOTOR, LCD,LED,RELAY AND ATMEGA
64A. NEVER USE CHATGPT OR OTHER AI SOFTWARE.
#include
#include
#include
#include "lcd.h"
// Define the connections
#define LDR1_PIN 0
#define LDR2_PIN 1
#define LDR3_PIN 2
#define RED_LED1_PIN PB0
#define GREEN_LED1_PIN PB1
#define RED_LED2_PIN PB2
#define GREEN_LED2_PIN PB3
#define RED_LED3_PIN PB4
#define GREEN_LED3_PIN PB5
#define SW1_PIN PE0
#define SW2_PIN PE1
#define GATE_MOTOR_PIN PC0
#define GATE_OPEN_TIME 15000// Gate open time in milliseconds
// Function prototypes
void initialize_hardware();
int read_ldr(int ldr_pin);
void set_led(int red_led_pin, int green_led_pin, int ldr_value);
void open_gate();
void close_gate();
void display_lcd_message(const char *message);
// Placeholder for vehicle detection
int vehicleAtGate(){
// Implement the actual vehicle detection logic here
// Return 1 if vehicle is detected, 0 otherwise
return 1; // For testing purposes, always return 1
}
int main(void){
initialize_hardware();
// Main program loop
while (1){
if (vehicleAtGate()){
if (PINE & (1<< SW1_PIN)){// SW1 is pressed
// Check LDR values and update LEDs
set_led(RED_LED1_PIN, GREEN_LED1_PIN, read_ldr(LDR1_PIN));
set_led(RED_LED2_PIN, GREEN_LED2_PIN, read_ldr(LDR2_PIN));
set_led(RED_LED3_PIN, GREEN_LED3_PIN, read_ldr(LDR3_PIN));
// Check if any parking spot is available
if ((read_ldr(LDR1_PIN)>300)||(read_ldr(LDR2_PIN)>300)||(read_ldr(LDR3_PIN)>300)){
display_lcd_message("Welcome"); // Display welcome message
} else {
display_lcd_message("Full Parking"); // Display full parking message
}
}
if (PINE & (1<< SW2_PIN)){// SW2 is pressed
// Open the gate only if there's at least one parking spot available
if ((read_ldr(LDR1_PIN)>300)||(read_ldr(LDR2_PIN)>300)||(read_ldr(LDR3_PIN)>300)){
open_gate();
_delay_ms(GATE_OPEN_TIME);
close_gate();
}
}
}
}
}
void initialize_hardware(){
// Initialize all pins and configurations
// Configure LDR pins as input
DDRA &= ~((1<< LDR1_PIN)|(1<< LDR2_PIN)|(1<< LDR3_PIN));
// Configure LED pins as output
DDRB |=(1<< RED_LED1_PIN)|(1<< GREEN_LED1_PIN)|(1<< RED_LED2_PIN)|(1<< GREEN_LED2_PIN)|(1<< RED_LED3_PIN)|(1<< GREEN_LED3_PIN);
// Initialize switch pins as input
DDRE &= ~((1<< SW1_PIN)|(1<< SW2_PIN));
// Initialize motor pin as output
DDRC |=(1<< GATE_MOTOR_PIN);
// Enable any necessary pull-up resistors
PORTE |=(1<< SW1_PIN)|(1<< SW2_PIN);
// Initialize LCD
lcd_init(LCD_DISP_ON_CURSOR);
lcd_clrscr();
lcd_gotoxy(0,0);
_delay_ms(50);
}
int read_ldr(int ldr_pin){
ADMUX =(ADMUX & 0xF8)|(ldr_pin & 0x07); // Select ADC channel with safety mask
ADCSRA |=(1<< ADSC); // Start single conversion
while (ADCSRA & (1<< ADSC)); // Wait for conversion to complete
return ADC; // Return the ADC value
}
void set_led(int red_led_pin, int green_led_pin, int ldr_value){
if (ldr_value <=300){
// Parking spot is occupied, turn RED LED on and GREEN LED off
PORTB |=(1<< red_led_pin);
PORTB &= ~(1<< green_led_pin);
} else {
// Parking spot is available, turn GREEN LED on and RED LED off
PORTB |=(1<< green_led_pin);
PORTB &= ~(1<< red_led_pin);
}
}
void open_gate(){
// Set the gate motor pin high to open the gate
PORTC |=(1<< GATE_MOTOR_PIN);
}
void close_gate(){
// Set the gate motor pin low to close the gate
PORTC &= ~(1<< GATE_MOTOR_PIN);
}
void display_lcd_message(const char *message){
// Implement LCD functions
lcd_clrscr();
lcd_gotoxy(0,0);
lcd_puts(message);
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!