Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need help with the code in c language

Status
Not open for further replies.

jakshay

Newbie level 5
Joined
Jun 12, 2010
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,377
hello..
I am working a car parking monitor system.....i am using simple ir led receiver and a comparator lm 324 connected to 89s52..

i am making six slots interfacing to micro controller 89s52.
the input pins are 2.0 to 2.6 and output pins are port connected to LCD (jhd 162a 16*2)

i want a program logic for the following

case1:when all parking slots are empty
LCD should display " vacant slots:b1,b2,b3,b4,b5,b6

case2: now a car gets parked in slot b1 (for example)
LCD output should be
empty slots :b2,b3,b4, b5,b6 (exclude b1)

case 3: say the parking slot b1 gets vacant again
b1 should again come in the list..

output on LCD , of empty slots=b1,b2,b3,b4,b5,b6

thanks in advance
 

firstly, make sure your hardware is ok,
(make a small blink program) then your LCD is ok, (try a Hello world program)

I'm assuming that when an Input is low, it means it's free, when it's high it means that it's occupied,

Code:
//add your hardware, and lcd routines here...
void main(void){
 lcd_init(); //init your lcd,
 P2=0x7F; //0 to 5 as inputs.

 while(1){
  lcd_clear(); //or command 0x01 followed by a 2ms delay
 lcd_print("VACANT SLOTS");
 lcd_cmd(0xC0); //or lcd_goto line 2
 if(P2.0) lcd_print("--");
 else lcd_print("b1");
 if(P2.1) lcd_print("--");
 else lcd_print("b2");
 if(P2.2) lcd_print("--");
 else lcd_print("b3");
 if(P2.3) lcd_print("--");
 else lcd_print("b4");
 if(P2.4) lcd_print("--");
 else lcd_print("b5");
 if(P2.5) lcd_print("--");
 else lcd_print("b6");
 delay_ms(1000); //needs some delay have a delay routine, some where...
 }
}

if you don't have LCD routines, go search!!! there are plenty, I have put mine in this forum also! do some work!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top