Jump to content
  • 0

Orange PI Win - Blink LED -


djmcg
 Share

Question

Hello

Ones again I`m would like to connect 1 LED to GPIO and make it blink .

I try to find tutorial on Wen but for OPI Win it`s not work (duo to lack tutorial for this models)

Could You help me wrote simple code to make LED start blinking?

With program included in Armbian to steering GPIO for my OPI

9968480900_1577182384_thumb.jpg

Thanks in advance.

:)

 

 

 

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
3 hours ago, djmcg said:

Could You help me wrote simple code to make LED start blinking?

Although some will say that way is almost deprecated, the simplest way is to use /sys/class/gpio !

Here is a small bash script that toggle the green LED of OPiWin which is on PH11/GPIO235 :

#!/bin/bash

echo 235 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio235/direction

while true; do
	echo 0 > /sys/class/gpio/gpio235/value
	sleep 0.25
	echo 1 > /sys/class/gpio/gpio235/value
	sleep 0.25
done

 

Link to comment
Share on other sites

Search Before Posting!

  • 0
18 minutes ago, djmcg said:

Could You advice how to run this script?

Yes, you can use "geany" or any other editor, paste the above code, save it as something like "led-flash.sh", make it executable using "chmod a+rx led-flash.sh" and run it from a shell using "./led-flash.sh".

(BTW, use the BCM numbers as the gpio numbers)

Link to comment
Share on other sites

  • 0

Hi

I`m update the code

#!/bin/bash

echo 37 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio37/direction

while true; do
	echo 0 > /sys/class/gpio/gpio37/value
	sleep 0.25
	echo 1 > /sys/class/gpio/gpio37/value
	sleep 0.25
done

But

I have error from terminal

 

Snap70.jpg

Link to comment
Share on other sites

  • 0
4 hours ago, djmcg said:

Looks not work.

Maybe some other apps has been using this gpio before running the script ?

Check the output of "cat /sys/kernel/debug/gpio" !

Also, check if same strange behaviour occur after a reboot, doing export/unexport should be coherent ...

Link to comment
Share on other sites

  • 0

After reboot is fine.

However I forgot mentioned I`m update script

#!/bin/bash

echo 37 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio37/direction
echo 38 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio38/direction
echo 39 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio39/direction
echo 101 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio101/direction
echo 36 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio36/direction

while true; do

#led1	
	echo 1 > /sys/class/gpio/gpio37/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio37/value
	sleep 0.01
	
#Led2
	echo 1 > /sys/class/gpio/gpio38/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio38/value
	sleep 0.01
	
# led3
	echo 1 > /sys/class/gpio/gpio39/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio39/value
	sleep 0.01
	
#led4
	echo 1 > /sys/class/gpio/gpio101/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio101/value
	sleep 0.01
#led5
	echo 1 > /sys/class/gpio/gpio36/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio36/value
	sleep 0.01
#led4
	echo 1 > /sys/class/gpio/gpio101/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio101/value
	sleep 0.01
# led3
	echo 1 > /sys/class/gpio/gpio39/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio39/value
	sleep 0.01
	
#Led2
	echo 1 > /sys/class/gpio/gpio38/value
	sleep 0.25
	echo 0 > /sys/class/gpio/gpio38/value
	sleep 0.01
	
	
	
done

Those command works

echo 0 > /sys/class/gpio/gpio37/value

 

Snap69.jpg

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...