2

I have a very small python script to control GPIOs:

pi@raspberrypi ~ $ sudo python gpio-test.py

#!/usr/bin/env python
try:
   from time import sleep
   import os
   import RPi.GPIO as GPIO

   GPIO.setmode(GPIO.BCM)
   GPIO.setup(6, GPIO.OUT)
   GPIO.output(6,True)              
   while True:   
      sleep(1);
finally:
   GPIO.cleanup()

The script does not take any effect with the GPIO6 where I have a led.

I've made another java program using the library pi4j and it works fine turning the led ON for 5 seconds:

package test;

import com.pi4j.io.gpio.GpioController;
import com.pi4j.io.gpio.GpioFactory;
import com.pi4j.io.gpio.GpioPinDigitalOutput;
import com.pi4j.io.gpio.PinState;
import com.pi4j.io.gpio.RaspiPin;

public class GPIOTest {

    static final GpioController gpio = GpioFactory.getInstance();;
    static final GpioPinDigitalOutput[] output = new GpioPinDigitalOutput[15];

    public static void main(String[] args) {

        output[6] = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_06, "output6",PinState.LOW);
        output[6].setState(PinState.HIGH);
        Thread.sleep(5000);
        output[0].setState(PinState.LOW);
        gpio.shutdown();
    }

}
4

gpio6 is only available on a Rev.3 board, a model B+.

See http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29 and use the proper Broadcom number for the gpio which is connected to your LED.

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.