#Include #Include #Include #Include #Define Char Char: F - Cpu
#Include #Include #Include #Include #Define Char Char: F - Cpu
* GccApplication3.c
*
* Created: 07-09-2020 21:09:23
* Author : Personal
*/
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <string.h>
#define F_CPU 4000000UL
char i=0,j=0,m=0;
char D[8]=" ";
ISR(INT0_vect)
{_delay_ms(1000);
m=m+1;// counting the votes of A
}
ISR(INT1_vect)
{
_delay_ms(1000);
j=j+1;// counting the votes of B
}
int main(void)
{
DDRA=0xff;//output port declaration
DDRB=0xff;//output port declaration
GICR=(1<<INT0)|(1<<INT1);
MCUCR=((1<<ISC01)|(0<<ISC00)|(1<<ISC11)|(0<<ISC10));
sei();
LCDcmd(0x01);// clear display screen
LCDcmd(0x0c);//Display on, Cursor Off
LCDcmd(0x38);// 8-bit, 2 lines mode// Function set:8-bit, 2 line, 5x7 Dots
LCDcmd(0x06);
LCDcmd(0x80);
while(1)
{
sprintf(D,"ENter");
LCDGoto(0,0);
LCDdisplay(D);
sprintf(D,"B-%d",j);
LCDGoto(0,1);
LCDdisplay(D);
}
}
void LCDcmd(char k)
{
PORTB=k;
PORTA=0x01;// 0 for RS, 0 for RW, 1 for EN makes 00000001 equals 1.
_delay_ms(200);
PORTA=0x00;// 0 for RS, 0 for RW, 0 for EN. High to low pulse required to give EN.
}
void LCDdisplay(char a[])
{
for(i = 0; i <strlen(a) ; i++ )
{
PORTB = a[i];
PORTA = 0x05;
_delay_ms(200);
PORTA = 0x04;
}
}
void LCDGoto(char x, char y)
{char add;// address
char c=0x00;
char b=0x40;
switch(y)
{
case 0: add = c+x;break;// address = 0x00+x- For first row
case 1: add = b+x;break;// address = 0x40+x- For second row
}
char addcmd=(0x80|add);// final address command needed to send.
LCDcmd(addcmd);// Sending the final address command
}
/*
* GccApplication1.c
*
* Created: 03-09-2020 11:37:25
* Author : Personal
*/
#include <avr/io.h> //header to enable data flow control over pins
#define F_CPU 4000000UL //telling controller crystal frequency attached
#include <util/delay.h> //header to enable delay function in program
#include <string.h>
#define E 5 //giving name “enable” to 5th pin of PORTD, since it Is connected to
LCD enable pin
#define RS 6 //giving name “registerselection” to 6th pin of PORTD, since is connected
to LCD RS pin