Jump to content

reptile

Members
  • Posts

    7
  • Joined

  • Last visited

Reputation Activity

  1. Like
    reptile got a reaction from rusatch in Trigger LED on Orange PI Zero Plus   
    ok, 2nd day and starting to better understand this, will explain it loudly for myself and anyone else:
     
    Though the answer was there from the beginning, too bad that it wasn't clear for meL
    http://linux-sunxi.org/GPIO
     
    First we need to "create" or "attach" the GPIO port using this command:
     
    sudo echo XX > /sys/class/gpio/export The XX is a complex calculation of the GPIO:
     
     
    so for Orange PI Zero plus 2 H5 (should be same for h3/h2) the RED led would on GPIO PA17 and GREEN LED on GPIO PL10  (Info from here: http://linux-sunxi.org/Xunlong_Orange_Pi_Zero_Plus_2 )
    The calculation would be (Letter A is 1, the "P" not counted): (1 -0) * 32 + 17 =  17  (For RED LED) while for Green LED: (12 - 1) * 32 + 10 = 362
     
    sudo echo 362 > /sys/class/gpio/export sudo echo 17 > /sys/class/gpio/export  
    Now lets check the status of the GPIOs:
     
    cat /sys/kernel/debug/gpio gpiochip1: GPIOs 0-223, parent: platform/1c20800.pinctrl, 1c20800.pinctrl: gpio-9 ( |reset ) out hi gpio-14 ( |sysfs ) out hi gpio-17 ( |sysfs ) in lo gpio-110 ( |sysfs ) in lo gpio-166 ( |cd ) in hi IRQ gpio-204 ( |usb0_id_det ) in lo IRQ gpiochip0: GPIOs 352-383, parent: platform/1f02c00.pinctrl, 1f02c00.pinctrl: gpio-358 ( |? ) out lo gpio-362 ( |sysfs ) in lo  
    The GPIOs should be "out" direction (i guess because we are outputting to it), so lets fix them:
    sudo echo out > /sys/class/gpio/gpio362/direction sudo echo out > /sys/class/gpio/gpio17/direction  
    Now that the direction is correct, lets try to switch them on or off:
    sudo echo 1 > /sys/class/gpio/gpio362/value sudo echo 0 > /sys/class/gpio/gpio362/value sudo echo 1 > /sys/class/gpio/gpio17/value sudo echo 0 > /sys/class/gpio/gpio17/value  
    Now that the LEDs are controllable, The  next challenge would be adding some rhythm to the led per hardware occasions such as heart beet, read/write..  i hope it will be easier than above
  2. Like
    reptile got a reaction from pfeerick in orange pi zero led   
    I was wondering about the same and i answered it here:
     
    For anyone landing here and can't find answer..
     
  3. Like
    reptile got a reaction from pfeerick in Trigger LED on Orange PI Zero Plus   
    ok, 2nd day and starting to better understand this, will explain it loudly for myself and anyone else:
     
    Though the answer was there from the beginning, too bad that it wasn't clear for meL
    http://linux-sunxi.org/GPIO
     
    First we need to "create" or "attach" the GPIO port using this command:
     
    sudo echo XX > /sys/class/gpio/export The XX is a complex calculation of the GPIO:
     
     
    so for Orange PI Zero plus 2 H5 (should be same for h3/h2) the RED led would on GPIO PA17 and GREEN LED on GPIO PL10  (Info from here: http://linux-sunxi.org/Xunlong_Orange_Pi_Zero_Plus_2 )
    The calculation would be (Letter A is 1, the "P" not counted): (1 -0) * 32 + 17 =  17  (For RED LED) while for Green LED: (12 - 1) * 32 + 10 = 362
     
    sudo echo 362 > /sys/class/gpio/export sudo echo 17 > /sys/class/gpio/export  
    Now lets check the status of the GPIOs:
     
    cat /sys/kernel/debug/gpio gpiochip1: GPIOs 0-223, parent: platform/1c20800.pinctrl, 1c20800.pinctrl: gpio-9 ( |reset ) out hi gpio-14 ( |sysfs ) out hi gpio-17 ( |sysfs ) in lo gpio-110 ( |sysfs ) in lo gpio-166 ( |cd ) in hi IRQ gpio-204 ( |usb0_id_det ) in lo IRQ gpiochip0: GPIOs 352-383, parent: platform/1f02c00.pinctrl, 1f02c00.pinctrl: gpio-358 ( |? ) out lo gpio-362 ( |sysfs ) in lo  
    The GPIOs should be "out" direction (i guess because we are outputting to it), so lets fix them:
    sudo echo out > /sys/class/gpio/gpio362/direction sudo echo out > /sys/class/gpio/gpio17/direction  
    Now that the direction is correct, lets try to switch them on or off:
    sudo echo 1 > /sys/class/gpio/gpio362/value sudo echo 0 > /sys/class/gpio/gpio362/value sudo echo 1 > /sys/class/gpio/gpio17/value sudo echo 0 > /sys/class/gpio/gpio17/value  
    Now that the LEDs are controllable, The  next challenge would be adding some rhythm to the led per hardware occasions such as heart beet, read/write..  i hope it will be easier than above
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines