Beruflich Dokumente
Kultur Dokumente
[ROLL N0.:-201501094]
DARSHAN| [ESD] |
Question [1]
ANSWER
void main() {
DDRA=0xFF;
while(1)
PORTA=0b11000000;//0
delay_ms(1000);
PORTA=0b11111001;//1
delay_ms(1000);
PORTA=0b10100100;//2
delay_ms(1000);
PORTA=0b10110000;//3
delay_ms(1000);
PORTA=0b10011001;//4
delay_ms(1000);
PORTA=0b10010010;//5
delay_ms(1000);
PORTA=0b10000010;//6
delay_ms(1000);
PORTA=0b11111000;//7
delay_ms(1000);
PORTA=0b10000000;//8
delay_ms(1000);
PORTA=0b10010000;//9
delay_ms(1000);
PORTA=0b10001000;//A
delay_ms(1000);
PORTA=0b10000011;//B
delay_ms(1000);
PORTA=0b11000110;//C
delay_ms(1000);
PORTA=0b10100001;//D
delay_ms(1000);
PORTA=0b10000110;//E
delay_ms(1000);
PORTA=0b10001110;//F
delay_ms(2000);
PORTA=0b10000110;//E
delay_ms(1000);
PORTA=0b10100001;//D
delay_ms(1000);
PORTA=0b11000110;//C
delay_ms(1000);
PORTA=0b10000011;//B
delay_ms(1000);
PORTA=0b10001000;//A
delay_ms(1000);
PORTA=0b10010000;//9
delay_ms(1000);
PORTA=0b10000000;//8
delay_ms(1000);
PORTA=0b11111000;//7
delay_ms(1000);
PORTA=0b10000010;//6
delay_ms(1000);
PORTA=0b10010010;//5
delay_ms(1000);
PORTA=0b10011001;//4
delay_ms(1000);
PORTA=0b10110000;//3
delay_ms(1000);
PORTA=0b10100100;//2
delay_ms(1000);
PORTA=0b11111001;//1
delay_ms(1000);
PORTA=0b11000000;//0
delay_ms(1000);
[Explanation of Steps]
[Short Description]
Question [2]
ANSWER
int
a[10]={0b11000000,0b11111001,0b10100100,0b10110000,0b10011001,0b1001001
0,0b10000010,0b11111000,0b10000000,0b10010000};
int count=0;
count=(count==99)?(0):(count+1);
// SREG.B7=1;
// GIFR.B6 = 0;
void main() {
DDRA=0xFF;
DDRB=0xFF;
DDRD=0x00;
GICR = 0x40;
MCUCR = 0x03;
SREG.B7=1;
while(1)
PORTA=a[count/10];
PORTB=a[count%10];
delay_ms(300);
[Explanation of Steps]
STEP.1: For first 7 Segment LED, Connect PORTA.B0 with a, PORTA.B1 with b,
PORTA.B2 with c, PORTA.B3 with d, PORTA.B4 with e, PORTA.B5 with f, PORTA.B6
with g, PORTA.B7 with dp, Applying VCC to common of the first 7 Segment LED.
For Second 7 Segment LED, Connect PORTB.B0 with a, PORTB.B1 with b,
PORTB.B2 with c, PORTB.B3 with d, PORTB.B4 with e, PORTB.B5 with f, PORTB.B6
with g, PORTB.B7 with dp and Applying VCC to common of the second 7 Segment
LED.
STEP.2: Push Button is connected to VCC and PORTD.B2(INT0), and here, resistor
is connected between VCC and ground. This VCC is common connected between
resistor and the push button.
Question [3]
ANSWER
/*
*/
int
SevenSegment_Cathod[]={0xC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X98}
;
int temp,count=0,flag1=0,flag2=0,flag3=0,flag4=0;
int count_time2=125;
/*
In multiplexing, data and selection lines are changed at very small time
*/
if(shift==0x10)
if (count==4)
// delay_ms(500);
void main() {
// PORT declaration
PORTA=0x01; //Initialize
//Timer Set-Up
TCCR0=0x0B;
OCR0=0xF9;
//Interrupt Set-Up
while(1)
//for(i=0;;i++)
if(flag1==10)
{ // store[0]=0;
flag1=0;
// store[0]=0;
flag2++;
// store[1]++;
if(flag2==6)
{ flag2=0;
// store[1]=0;
flag3++;
// store[2]++;
if(flag3==10)
{ flag3=0;
// store[3]=0;
flag4++;
// store[3]++;
if(flag3==4&&flag4==2)
{ flag1=0;
// store[0]=0;
flag2=0;
// store[1]=0;
flag3=0;
// store[2]=0;
flag4=0;
//store[3]=0;
store[0]=SevenSegment_Cathod[flag1++];
store[1]=SevenSegment_Cathod[flag2];
store[2]=SevenSegment_Cathod[flag3];
store[3]=SevenSegment_Cathod[flag4];
delay_ms(100);
}
[Explanation of Steps]
STEP.1: connect 0,1,2,3,4,5,6,Vcc and GND pins of PORTC, 0,1,2,3 and GND
pins of PORTA with breadboard.
STEP.2: joint a four 7-segment LEDs and resistors with breadboard.
STEP.3: build the code on ATMEGA board.
STEP.4: run the code.
[Short Description]
There are four 7 segment LEDS use for this experiment. For
this 4 7 segment LED display we want 4 port but if we want to do any
project and need this digital clock than what to do? For that purpose we
change logic which use single port or double port so for that we use shift
delay which means in single port we will display 4 7-segment LEDS. We
use another port for shift which means when any bits of that port is 1 at
that time it display that port LED , For example here we use PORTA as
shifting so when PORTA.B1 is 1 than it will display LED 1 st . We wanted to
display HH-MM. means 2 LED for displaying hours , 2 LED for displaying
minutes and second display at last LED of minutes pointer means that
spot LED blinking 60 time and count 1 minute.
In code we use 4 flag for displaying 4 7-segment LEDS and
use PORTA for which 7-segment LED is display at a point in time. For
practical purpose, due to unavailability of enough wires, we have tried to
show the HH and MM part separately and increased the speed of clock in
order to check that all the resets are properly performed