1

I have two simple scripts, one in Python, one in bash to turn on and off a LED. I don't know what I'm doing wrong but if a run the bash script nothing happen, while the Python script It works flawless.

The strange thing is that if I run the Python script and after that I run the bash script...it works

after the reboot if I run the bash script first doesn't work

Is there something that I need to add in the /boot/config.txt ?

BASH script

   #!/bin/bash
gpio mode 18 out
echo LED on
gpio -g write 18 1
sleep 1
echo LED off
gpio -g write 18 0

Python script

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(18,GPIO.OUT)
print ("LED on")
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
print ("LED off")
GPIO.output(18,GPIO.LOW)
1

gpio mode 18 out will not do anything, because there is no Wiring Pi pin 18

gpio -g mode 18 out or gpio mode 1 outwill work

  • I confirm it works now – Luca Scalvi Apr 23 at 10:02

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.