Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

controle led with pus button

Status
Not open for further replies.

georgetwo

Member
Hi every one
Im new to pic. Class assignment
I need your help in making my pic18f4550 respond directly to the input of one of the ports.
Example
port c is 8bit output connected to 8 leds

port d is input connected to 8 push buttons

now if i push one button on port c i need the same bit on port b to turn on.

Im using c with Hi-tech c and pic kit 2
thanks for reading
thanks for your suggestions
 
Hi

You could multiplex the LEDs. Something like this could do:

Code:
if (PININ1 = 1)
{
PINOUT1 = 1;
[B]
TMRO pause[/B]

PINOUT1 = 0;
}

if (PININ2 = 1)
{
PINOUT2 = 1;

[B]TMRO pause[/B]

PINOUT2 = 0;
}

ect.

Then have this for each of the inputs/outputs repeating lots and lots.


Tom
 
Just read the Port D (Dig. In) into the w register and write it to the PORT C Register (Dig. out). Two instructions.

movf PORTD,w
movwf PORTC

loop that and you're done.

That's the 16F asm version. 18F has the movff instruction which could prob be all u need. No multiplexing required as u have a pin per button and an LED per pin.

C would be equally simple.
 
Last edited:
Thanks for the idear
but how do i express
it in c? i red a book which used assembly as shown
mov A, P0
mov P1, A
just these two
 
Something like this would test for change.

Code:
	while(1)
        (
          If  (PortA <> PORTB);
               PortA = PORTB:
  )
)
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top