- This topic has 0 replies, 1 voice, and was last updated 12 years, 9 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
|
Microcontroller › PIC › PIC 16F84A pins into array
Hi
I’m newbie in embedded system programming but not in C/C++ or C#. Here is the situation, I want to put all the portB pins into an array to simply use a loop that blinks some leds following a determined order here is the code so I tried to use the output_bit(pin,value) which Ifound in the mikroC library but in vain the compiler doesn’t recognise it. So how to put all those pins of the portB into an array? For thurther details here is my code:
//Shift the led to left
void moveleft()
{
int i = 0;
while(PORTB.F7!=1)
{
//Set the value of the pin i to 1
output_bit(i,1);
//Delay
Delay_ms(1000);
i++;
}
}
//Shift the led to right
void moveright()
{
int i = 7;
while(PORTB.F7!=1)
{
//Set the value of the pin i to 1
output_bit(i,1);
//Delay
Delay_ms(1000);
i–;
}
}
void initialize()
{
TRISB = 0;
PORTB = 0xFF;
PORTB.F0 = 0;
}
//The main function
void main()
{
initialize();
while(1)
{
if(PORTB.F7!=1) moveleft();
Delay_ms(1000);
if(PORTB.F0!=1) moveright();
Delay_ms(1000);
}
}
Thank you