Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help for code 16f84A

Status
Not open for further replies.

MARWEN007

Junior Member level 2
Junior Member level 2
Joined
Apr 16, 2011
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,481
Hi everyone I have a small gap in a program
I'm still in good beginner programmtion but I want improved my knowledge.
I want to set the 16F84A with mikroC for it illuminates the LEDs at specific requirement I will explain my purpose
* two LED lights in the PORTB when I press a Button (entered the port A) I want LED1 port B is extinguished when I release either on, and the same principle for the second led2 except when both botton are supporting a 3 rd lED should be lit means;
is a0, a1 of the input b0, b1 and b2 outputs
** a0 = 0 and a1 = 0 => b0 = 1 and b1 = 0
** a0 = 1 and a1 = 0 => b0 = 0 and b1 = 1
** a0 = 0 and a1 = 1 => b0 = 1 and b1 = 0
* a0 = 0 and a1 = 0 => b0 = 0 and b1 = 0 and b2 = 1

I realized a small program and I simulate it on proteus isis it works with a small defect in the program when I press the botton LED 1 is off and that I release it remains extinguished!


Code:
void main()
 {

TRISB = 0x00;                                  // Configure PORTC as output
PORTB = 0;
TRISA = 0xff;                                  // Configure PORTC as output
PORTA = 0;

   debut:
   do  {


if(portA.f0==0&&portA.f1==0)

{
  portB.f0=1;
  portB.f1=1 ;
 }
  else if (portA.f0==1&&portA.f1==0)
  { portB.f0=1;
    portB.f1=0; }
  else if  (portA.f0==0&&portA.f1==1)
     { portB.f0=0 ;
       portB.f1=1 ;}
       

       else if
       (portA.f0==1&&portA.f1==1)
       { portB.f0=0;
         portB.f1=0 ;
         portB.f2=1 ;

       }
       else if (portA.f0!=1||portA.f1!=1)
        {goto debut;}
      }
     while (1);
 

what is your problem, i cant able to understand clearly.

for your all conditions, which condition is not working?

and your if loop would make the trouble, go with the separate brackets like ((cond...)&&(cond...)).
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top