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:


   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*/  
   int i;
   for(i = 0; i < 60; i++){


   /* Stop DMA, release resources */

   return 0;
void initZero(){
      gpioWrite(4,  1); /* off */   
      gpioWrite(17, 1); /* off */
      gpioWrite(27, 1); /* off */            

void blinkBlue(){
      gpioWrite(4, 1); /* off */
      gpioWrite(4, 0); /* on */

void blinkGreen(){
      gpioWrite(17, 1); /* off */
      gpioWrite(17, 0); /* on */

void blinkRed(){
      gpioWrite(27, 1); /* off */
      gpioWrite(27, 0); /* on */

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.

  • The most likely reason for unexpected activity on GPIO4 (pin 7) is that you have a dtoverlay=w1-gpio entry in /boot/config.txt.
    – joan
    Sep 27, 2016 at 15:29

1 Answer 1


I switched to a common cathode LED and it works fine now. In my code, I notice that the Pins are set as OUTPUTS, but a default state, high or low is not set. The default setting, would be low, on outputs, so I should have specified HIGH for the pin setting. Alternatively, a common cathode LED also fixes the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.