CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Not work
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 03, 2015 11:35 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group