Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

These is the hardware in proteus for the simulation: Implement a people counter with the following characteristics in C code: The count must have a

These is the hardware in proteus for the simulation:

image text in transcribed

Implement a people counter with the following characteristics in C code: The count must have a minimum of 0 and a maximum of 999 people. There will be 3 switches: o +: Increases the people count by one (as long as it does not reach the maximum of 999) o -: Decreases the people count by one (as long as it does not reach the minimum of 0) o Clr: initialize the counter to 0 The rebound must be handled properly in the switches, that is, if it is pressed once, it will not you will need to do the corresponding function more than once. The number should always be shown in 3 positions with zeros preceding the number if it is necessary. For example: 000, 009, 010, 100, and 999.

it is necesary to use the following library for display

//Library for using a LCD by Agustin Dominguez Version3 // Copy this file to "inc" folder and put LCD connections before the #include //If the LCDs connections change, you need to change the #define below and SetupLCD for defining the necessary outputs // For example // #asm // .equ __lcd_port=0x0C // .equ __lcd_EN=1 // .equ __lcd_RS=0 // .equ __lcd_D4=2 // .equ __lcd_D5=3 // .equ __lcd_D6=4 // .equ __lcd_D7=5 // #endasm // #include

//You need to copy this library to the inc folder

#include unsigned char cursor;

#pragma used+

void SendDataBitsLCD(unsigned char dato); void WriteComandLCD(unsigned char Comando); void PulseEn();

/* Procedimiento para configurar el LCD. Es necesaria ejecutar al inicio para el correcto funcionamiento */ /* en un LCD fsico (no es crtico para simulcacin slo en Proteus*/ void SetupLCD() { unsigned char TableSetup[12]={3,3,3,2,2,12,0,8,0,1,0,6}; unsigned char i; #asm SBI __lcd_port-1,__lcd_EN SBI __lcd_port-1,__lcd_RS SBI __lcd_port-1,__lcd_D4 SBI __lcd_port-1,__lcd_D5 SBI __lcd_port-1,__lcd_D6 SBI __lcd_port-1,__lcd_D7 #endasm //DDRF=DDRF|0x3F; //Outputs for LCD delay_ms(50); for (i=0;i

void SendDataBitsLCD(unsigned char dato) { if ((dato&0x08)!=0) #asm("SBI __lcd_port,__lcd_D7") //D7=1; else #asm("CBI __lcd_port,__lcd_D7") // D7=0; if ((dato&0x04)!=0) #asm("SBI __lcd_port,__lcd_D6") // D6=1; else #asm("CBI __lcd_port,__lcd_D6") // D6=0; if ((dato&0x02)!=0) #asm("SBI __lcd_port,__lcd_D5") else #asm("CBI __lcd_port,__lcd_D5") // D5=0; if ((dato&0x01)!=0) #asm("SBI __lcd_port,__lcd_D4") //D4=1; else #asm("CBI __lcd_port,__lcd_D4") //D4=0; }

void WriteComandLCD(unsigned char Comando) { unsigned char tempComando; #asm("CBI __lcd_port,__lcd_RS") //RS=0; delay_ms(2); tempComando=Comando&0xF0; tempComando=tempComando>>4; SendDataBitsLCD(tempComando); PulseEn(); tempComando=Comando&0x0F; SendDataBitsLCD(tempComando); delay_ms(2); PulseEn(); }

/* Sends a character to LCD where the cursor is located*/ void CharLCD(unsigned char dato) { unsigned char tempdato; #asm("SBI __lcd_port,__lcd_RS") // RS=1; delay_ms(2); tempdato=dato&0xF0; tempdato=tempdato>>4; SendDataBitsLCD(tempdato); PulseEn(); tempdato=dato&0x0F; SendDataBitsLCD(tempdato); delay_ms(2); PulseEn(); }

/* Sends a fixed string to LCD*/ void StringLCD(flash unsigned char Mensaje[]) { unsigned char i; i=0; do{ CharLCD(Mensaje[i++]); }while(Mensaje[i]!=0); }

/* Sends a fixed string to LCD with delay (msec) among each character*/ void StringLCD2(flash unsigned char Mensaje[],unsigned int tiempo) { unsigned char i; i=0; do{ CharLCD(Mensaje[i++]); delay_ms(tiempo); }while(Mensaje[i]!=0); }

/* Sents a varible string to LCD*/ void StringLCDVar(unsigned char Mensaje[]) { unsigned char i; i=0; do{ CharLCD(Mensaje[i++]); }while(Mensaje[i]!=0); }

/* Erase all LCD */ void EraseLCD( ) { WriteComandLCD(1); }

/* Move coursor to the position (x,y) */ /* x: Column number 0 a 15 */ /* y: Row number 0 or 1 */ void MoveCursor(unsigned char x, unsigned char y) { switch (y) { case(0): WriteComandLCD(0x80+x); break; case(1): WriteComandLCD(0xC0+x); break; case(2): WriteComandLCD(0x94+x); break; case(3): WriteComandLCD(0xD4+x); break; } }

/* It appers the Underscore Cursor _ */ void UnderscoreCursor() { cursor=cursor|0x02; WriteComandLCD(cursor); }

/* It disappers the Underscore Cursor*/ void NoUnderscoreCursor() { cursor=cursor&0xFD; WriteComandLCD(cursor); }

/* It appers the Blink cursor */ void BlinkCursor() { cursor=cursor|0x01; WriteComandLCD(cursor); }

/* It disappears the Blink cursor */ void NoBlinkCursor() { cursor=cursor&0xFE; WriteComandLCD(cursor); }

/* Crate a custum character Parameters: NoCaracter.- number from 0 to 7 (you can have 8 custum characters) datos[8].- Array with 8 bytes with the draw of the custum character, a 1 stands for a black pixel. 0x00 $ $ 0x0A $ $ $ 0x15 $ $ 0x11 $ $ 0x0A $ 0x04 Example: unsigned char Letra0[8] = {0x00, 0x0A, 0x15, 0x11, 0x0A, 0x04}; //Caracter como un corazn CreateChar(0, Letra0); For display this character use: CharLCD(0); */

void CreateChar(unsigned char NoCaracter, unsigned char datos[8]) { unsigned char i; WriteComandLCD(0x40+NoCaracter*8); for (i=0;i

#pragma used-

LCD1 LMO16LBL

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transact SQL Cookbook Help For Database Programmers

Authors: Ales Spetic, Jonathan Gennick

1st Edition

1565927567, 978-1565927568

More Books

Students also viewed these Databases questions

Question

Conduct a needs assessment. page 269

Answered: 1 week ago