please help meSolutioninclude header to enable data flow con

please help me

Solution

#include <avr/io.h> //header to enable data flow control over pins

#define F_CPU 1000000   //telling controller crystal frequency attached

#include <util/delay.h> //header to enable delay function in program

int main(void)

{

DDRB = 0x00; // Taking portB as input port

DDRA = 0xFF; //taking porta as output port

DDRD = 0b11111111; //taking portd as output

int DISPLAY1 [10] = {0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x67};

//character display values from 0-9

int c = 0;

int i=0;

int d = 0;

int one = 0; //memory for storing ones place value

int ten =0; //memory for storing tens place value

while(1)

{

if (bit_is_clear(PINB,0)) //when button one is pressed

{

if (i<21)

{

i++; //increment integer ‘i’ by one if its less than 21

}

}                         

if (bit_is_clear(PINB,1)) // when button 2 is pressed

{

if (d<21)

{

d++; // increment integer ‘d’ by one if its less than 21

}

}

if (i>20) //if ‘i’ was executed more than 21 times

{

if (c<99) //if counter value less than 99

{

c++; //increment counter value

}

i=0; //put i to zero

}

if (d>20) // if ‘d’ was executed more than 21 times

{

if (c>0) //if counter value is greater than 0

{

c--; //decrease the value by one

}

d=0; //put d to zero

}

if (c<10) // if counter value is less than 10

{

one = c; // ones place is equal to counter value or c

ten = 0; // tens place is equal to zero as ‘c’ value is less than 10

}

if (c>=10) //if count value is greater than or equal to 10

{

ten = c/10;//as intergers cannot hold decimal points(12/10=1.2),for integer its‘1’

one = c-(ten*10);//ones place

}

PORTD |=(1<<PIND6); //turn ones place displaying display transistor ON

PORTA = DISPLAY1[one]; //put value at porta which is needed for corresponding digit display

_delay_ms(10); //wait for vision illusion

PORTD &=~(1<<PIND6); // turn ones place displaying display transistor OFF

PORTD |=(1<<PIND5); // turn tens place displaying display transistor ON

PORTA = DISPLAY1[ten]; //put value at porta which is needed for corresponding digit display

_delay_ms(10);

PORTD &=~(1<<PIND5);// turn tens place displaying display transistor OFF

}

}

please help meSolution#include <avr/io.h> //header to enable data flow control over pins #define F_CPU 1000000 //telling controller crystal frequency atta
please help meSolution#include <avr/io.h> //header to enable data flow control over pins #define F_CPU 1000000 //telling controller crystal frequency atta
please help meSolution#include <avr/io.h> //header to enable data flow control over pins #define F_CPU 1000000 //telling controller crystal frequency atta

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site