Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with blinking two LEDS (they do not alternate)
10-05-2016, 03:58 PM,
#1
Problem with blinking two LEDS (they do not alternate)
Hi,

I have this code which is suppose to alternate the blinking between the USERLED and the LED on pin 12. I have a pinguino with the PIC18F4550 chip.

void setup() {
 pinMode(USERLED, OUTPUT);  
 pinMode(12,OUTPUT);
}

void loop() {
 digitalWrite(USERLED, HIGH);
 digitalWrite(12, LOW);
 delay(500);
 digitalWrite(USERLED, LOW);
 digitalWrite(12, HIGH);
 delay(500);
}

However, both LEDs blink on an off at the same time rather than alternating. Also when I try this on v11 the timing is correct but when i try it on v12 the timing is way faster..

Is something wrong with my code or there is bug?

thanks
earl
Reply
10-05-2016, 04:03 PM,
#2
RE: Problem with blinking two LEDS (they do not alternate)
(10-05-2016, 03:58 PM)earlct Wrote: Hi,

I have this code which is suppose to alternate the blinking between the USERLED and the LED on pin 12. I have a pinguino with the PIC18F4550 chip.

void setup() {
 pinMode(USERLED, OUTPUT);  
 pinMode(12,OUTPUT);
}

void loop() {
 digitalWrite(USERLED, HIGH);
 digitalWrite(12, LOW);
 delay(500);
 digitalWrite(USERLED, LOW);
 digitalWrite(12, HIGH);
 delay(500);
}

However, both LEDs blink on an off at the same time rather than alternating. Also when I try this on v11 the timing is correct but when i try it on v12 the timing is way faster..

Is something wrong with my code or there is bug?

thanks
earl

The timing problem on v12 seems only to be when i use the xc8 compiler. Timing is ok with SDCC compiler.

But i still can't get the LEDs to alternate blinking.
Reply
10-05-2016, 05:30 PM, (This post was last modified: 10-05-2016, 05:31 PM by gtcbreizh.)
#3
RE: Problem with blinking two LEDS (they do not alternate)
(10-05-2016, 03:58 PM)earlct Wrote: Hi,

I have this code which is suppose to alternate the blinking between the USERLED and the LED on pin 12. I have a pinguino with the PIC18F4550 chip.

void setup() {
 pinMode(USERLED, OUTPUT);  
 pinMode(12,OUTPUT);
}

void loop() {
 digitalWrite(USERLED, HIGH);
 digitalWrite(12, LOW);
 delay(500);
 digitalWrite(USERLED, LOW);
 digitalWrite(12, HIGH);
 delay(500);
}

However, both LEDs blink on an off at the same time rather than alternating. Also when I try this on v11 the timing is correct but when i try it on v12 the timing is way faster..

Is something wrong with my code or there is bug?

thanks
earl

Hi earl

USERLED is connected anode side to 5V VCC. Therefore to switch it on you have to set RA4 to 0.

For the timing you have to correct delayms.c lines 56 & 123 it is __XC8__ instead of _XC8_

André
Reply
10-05-2016, 09:15 PM,
#4
RE: Problem with blinking two LEDS (they do not alternate)
delay has been fixed for both SDCC and XC8.
Please update your testing copy.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply
11-05-2016, 03:29 PM,
#5
RE: Problem with blinking two LEDS (they do not alternate)
(10-05-2016, 09:15 PM)regis Wrote: delay has been fixed for both SDCC and XC8.
Please update your testing copy.


I updated and both seem to be working fine!

THANKS Regis!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)