I am using picf877.
How I can make pin_b[i] varies from pin_b0 to pin_b7?
I want to make 8 switches on PORTB to control 8 LEDs on PORTC
Is there easier way to make this instead of loops?
Last question
Is there a function to test if any pin in portB got 1 signal from out?
I mean:
check(PORTB)
If 1 comes to pin_b3 for example, check(portb) should return pin_b3.
Thanks and sorry for my bad english.
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Sat Oct 16, 2010 9:18 pm
You could create an array of 8 bytes, and initialize it to the list of pin
names that you want. The pin names (constants) are given in the
16F877.h file. Example:
http://www.ccsinfo.com/forum/viewtopic.php?t=29344
scottc
Joined: 16 Aug 2010 Posts: 95
Posted: Sun Oct 17, 2010 2:11 am
There are a number of ways to do what you want. You could capture
port b, and test it to display the contents on port c. You would want to
pull up each pin to VCC using a 47k resistor.
I believe this might do the trick for you.
Code:
void main(void)
{
byte switches; //variable to hold switch data
switches = input_b(); //switches connected to port b
output_c (switches); // Port C display's contents of port B
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum