Thursday, 17 October 2013

Here the switch is connected to the PORTB pin no 0 and 1, for Up and Down Counter. The value of the counter will decrease at the time it reaches to max value (i.e. 9). Till then switch 2 will not work. Only access to the switch for making counter in forward direction is allowed. When counter reaches to the 9, switch 1 will stop working and only switch 2 will come into action.



/*
 *
 *
 * Created: 17/10/13 3:24:24
 *  Author: Raj Prajapati.
 */



#include <avr/io.h> //Header file for AVR input/output.
#include <util/delay.h> //header file for delay.
char ssd[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; // Hexadecimal values for the 7 Segment display generated by the look up table
char i=-1;
int main(void)
{
char flag1=0,flag2=0,sw1=0,sw2=1; //flag for two switch.
DDRA=0XFF;
    while(1)
    {

if (bit_is_clear(PINB,0)&&flag1==0i&&i!=9&&sw1==0) //check switch 1 is Pressed.
{
++i;
PORTA=ssd[i];

flag1=1;
sw2=1;
if (i==9)
{
sw2=0;
sw1=1;
}
}
if (bit_is_set(PINB,0)) //Release condition for pressed switch 1.
{
flag1=0;
}
if (bit_is_clear(PINB,1)&&flag2==0&&i>0&&sw2==0) //check switch 2 is pressed.
{
--i;
PORTA=ssd[i];
flag2=1;
sw1=1;
if (i==0)
{
sw2=1;
sw1=0;
}
}
if (bit_is_set(PINB,1)) //Release condition for pressed switch 1.
{
if (i<0&&flag2==1)
{
i=-1;
}
flag2=0;
}

}
}


AVR STUDIO


PROTEUS :


Click here for VIDEO......

2 comments:

  1. Hi
    I needed 4 digit 7 segment led display with switch like gas prices display
    Please help me
    How can make

    ReplyDelete
  2. kalo dibuat jadi 2 sven segmentnya gimana gan

    ReplyDelete

Blogroll

Copyright © 2013 RAJ PRAJAPATI (raj@electronicsrj.com)

Comments

About Projects

We also Provide support in making Electronics Projects at different level at Cheapest price. Contact Us for the further help.