I was trying to light an LED using RPi.GPIO on my Raspberry Pi 2 and it's not working. I'm able to do the same using pi4j library in Java. Following is the Java code which I have used to light LED.
final GpioController gpio = GpioFactory.getInstance(); final GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_01, "MyLED", PinState.LOW); pin.setShutdownOptions(true, PinState.LOW); pin.high(); Thread.sleep(1000); pin.low(); gpio.shutdown();
And my python code using RPi.GPIO is,
import RPi.GPIO as GPIO import time pin = 12 GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(pin, GPIO.OUT) GPIO.output(pin, GPIO.HIGH) time.sleep(5) GPIO.output(pin, GPIO.LOW) GPIO.cleanup(pin)
What might be the reason for this issue? Since pi4j is working I think no issues with my Raspberry Pi. I'm a newbie to Raspberry Pi, any help will be appreciated.