I have a raspberry pi B v1.1, with raspbian. I am using GPIO pins 4,17,27, to illuminate an RGB LED.
My problem is that GPIO Pin 4 flashes randomly. Ok, not exactly randomly, it seems to flash briefly once every 10 seconds. Even when my program is running, or when my program is off. The flashing, makes the color change, when it should not.
I don't recall setting a start up script, or anything else to use that pin. Im not sure why it is flashing.
Here is my source code:
/*
pulse.c
gcc -o pulse pulse.c -lpigpio -lrt -lpthread
sudo ./pulse
*/
#include <stdio.h>
#include <pigpio.h>
void blinkRed();
void blinkGreen();
void blinkBlue();
void initZero();
int main(int argc, char *argv[]){
if (gpioInitialise() < 0){
fprintf(stderr, "pigpio initialisation failed\n");
return 1;
}
/* Set GPIO modes */
gpioSetMode(4, PI_OUTPUT); //blue
gpioSetMode(17, PI_OUTPUT); //green
gpioSetMode(27, PI_OUTPUT); //red
/*init io to zero*/
initZero();
int i;
for(i = 0; i < 60; i++){
blinkRed();
}
/* Stop DMA, release resources */
initZero();
gpioTerminate();
return 0;
}
void initZero(){
gpioWrite(4, 1); /* off */
gpioWrite(17, 1); /* off */
gpioWrite(27, 1); /* off */
}
void blinkBlue(){
gpioWrite(4, 1); /* off */
time_sleep(0.5);
gpioWrite(4, 0); /* on */
time_sleep(0.5);
}
void blinkGreen(){
gpioWrite(17, 1); /* off */
time_sleep(0.5);
gpioWrite(17, 0); /* on */
time_sleep(0.5);
}
void blinkRed(){
gpioWrite(27, 1); /* off */
time_sleep(0.5);
gpioWrite(27, 0); /* on */
time_sleep(0.5);
}
I made a couple videos of it miss behaving, and will attach those when I find a good resource to do that with.
My LED is Common Anode (common V+), and I am using 470 ohm resistors on the 3.3V power supply pins.
dtoverlay=w1-gpio
entry in/boot/config.txt
.