PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 03, 2015 11:35 am |
|
|
Quote: | I try this, but the same error 1,2,3,4 (blink 2 times),3,2 and stop.
int16 pins[5] = {PIN_A0,PIN_A1,PIN_A2,PIN_A4};
for(i=4; i>0; i--) //FOR loop goes from the last LED to first
{
output_high(pins[i]); //turn the LED on
delay_ms(200); //wait 200ms
output_low(pins[i]); //turn the LED off
delay_ms(200); //wait 200ms
}
|
You are starting at pins[] array index 4, but you don't have a pin defined
for that array index. You only have pins defined for array indexes 0-3.
Also the index range for your for() loop goes from 4 to 1. But this is C,
not basic. Arrays start at index 0. |
|