Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!
Paste
Pasted as C by Tushar ( 11 years ago )
/*
* MyFirstproject.c
*
* Created: 14-Jan-13 6:50:18 PM
* Author: Lalit
*/
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
#include <avr/io.h>
#include <util/delay.h>
#include <avr/eeprom.h>
volatile uint16_t digits[4]={0,0,0,0};
void breakup(uint16_t num)
{
DDRD=0xFF;
PORTD=0xFF;
unsigned int i=0;
while(num!=0)
{
digits[i]=num;
num=num/10;
i++;
}
for(i=0;i<4;i++)
{
PORTD=(0<<i);
display(digits[i]);
_delay_ms(5);
PORTD=(1<<i);
}
}
void display(uint16_t num)
{
DDRB=0xFF;
PORTB=0x00;
switch(num)
{
case 0:
PORTB=0x7E;
break;
case 1:
PORTB=0x30;
break;
case 2:
PORTB=0x6D;
break;
case 3:
PORTB=0x79;
break;
case 4:
PORTB=0x33;
break;
case 5:
PORTB=0x5B;
break;
case 6:
PORTB=0x5F;
break;
case 7:
PORTB=0x70;
break;
case 8:
PORTB=0x7F;
break;
case 9:
PORTB=0x7B;
break;
}
}
int main(void)
{
int c;
DDRB=0xFF;
DDRC=0x00;
PORTC=0x01;
c=0
while(1)
{
if(PINC==0x00)
{
c++;
breakup(c);
_delay_ms(1200);
}
else
breakup(c);
}
}
Revise this Paste