Energia 12, V1.5 LP with G2553 chip in the socket, board has crystal soldered on. One LED on P1.6, the other on P2.5.
Strange little thing seen using the code below, modified "Fade" example.
Basically, it should fade two LED's in and out where one is bright and the other is dim and they alternate- one fades out as the other fades in, and vice versa. Occasionally, one LED or the other will flicker, or 'flash' brightly when it should be dim or go dim when it should be bright. I've tried a few different LED's ranging from small reds to large whites and greens and the glitch occurs regardless of the LED used.
A little background- I'm trying to make something up for my neighbor who has an HO scale model train set and am trying to simulate the RR crossing signs which had alternating red lights. Part of it would include a proximity sensor to detect the train and light the semaphores as needed so running one MSP to light multiple crossings seemed like a good idea, at the time.
I've also tried using one 'brightness' variable and subtracting it from the maximum brightness value but it still flickers.
Strange little thing seen using the code below, modified "Fade" example.
Basically, it should fade two LED's in and out where one is bright and the other is dim and they alternate- one fades out as the other fades in, and vice versa. Occasionally, one LED or the other will flicker, or 'flash' brightly when it should be dim or go dim when it should be bright. I've tried a few different LED's ranging from small reds to large whites and greens and the glitch occurs regardless of the LED used.
A little background- I'm trying to make something up for my neighbor who has an HO scale model train set and am trying to simulate the RR crossing signs which had alternating red lights. Part of it would include a proximity sensor to detect the train and light the semaphores as needed so running one MSP to light multiple crossings seemed like a good idea, at the time.
I've also tried using one 'brightness' variable and subtracting it from the maximum brightness value but it still flickers.
#define LED1 13
#define LED2 14
int brightness1 = 0; // how bright LED1 is
int brightness2 = 32; // how bright LED2 is
int fadeAmount = 1; // how many points to fade the LED by
void setup() {
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
}
void loop() {
analogWrite(LED1, brightness1);
analogWrite(LED2, brightness2);
brightness1 = brightness1 + fadeAmount;
brightness2 = brightness2 - fadeAmount;
if (brightness1 == 0 || brightness1 == 32) {
fadeAmount = -fadeAmount ;
}
delay(30);
}