Skip to main content
Remove "SOLVED" tagging in title. Accepting one of the answers marks the issue as resolved.
Link
Kusalananda
  • 356.2k
  • 42
  • 737
  • 1.1k

SOLVED - GPIO Errors - "echo: I/O error" and "write error: Device or resource busy"

edited title
Link

SOLVED - GPIO Errors when trying to run an LED on breadboard (absolute beginner)- "echo: I/O error" and "write error: Device or resource busy"

added 2 characters in body
Source Link

I've been trying the past 6 hours to run a very simple LOOKING code. It just turns an LED hooked to pin 18 on and off... This is on a raspberry PI 4.

I've tried using different pins I've tried adding sudo sh -c "..." I've tried single vs. double quotes

When running the following code, I get the error sh: 1: echo: echo: I/O error

#!/bin/bash

sudo sh -c 'echo 18 > /sys/class/gpio/export'

sudo sh -c 'echo "out" > /sys/class/gpio/gpio18/direction'

while [ $COUNTER:-1t:10000 ]; do
    sudo sh -c 'echo 1 > /sys/class/gpio/gpio18/value'
    sleep 1
    sudo sh -c 'echo 0 > /sys/class/gpio/gpio18/value'
    sleep 1
done

sudo sh -c 'echo 18 > /sys/class/gpio/unexport'

And when I run the "non-sudo" version, I get the error ./Lab1EX4_1.sh: line 4: echo: write error: Device or resource busy

#!/bin/bash

echo "18" > /sys/class/gpio/export

echo "out" > /sys/class/gpio/gpio18/direction

while [ $COUNTER:-1t:10000 ]; do
    echo 1"1" > /sys/class/gpio/gpio18/value
    sleep 1
    echo 0"0" > /sys/class/gpio/gpio18/value
    sleep 1
done

echo 18"18" > /sys/class/gpio/unexport

This has got me so mad...

Thank you peeps! I just want a blinky light :D

I've been trying the past 6 hours to run a very simple LOOKING code. It just turns an LED hooked to pin 18 on and off... This is on a raspberry PI 4.

I've tried using different pins I've tried adding sudo sh -c "..." I've tried single vs. double quotes

When running the following code, I get the error sh: 1: echo: echo: I/O error

#!/bin/bash

sudo sh -c 'echo 18 > /sys/class/gpio/export'

sudo sh -c 'echo "out" > /sys/class/gpio/gpio18/direction'

while [ $COUNTER:-1t:10000 ]; do
    sudo sh -c 'echo 1 > /sys/class/gpio/gpio18/value'
    sleep 1
    sudo sh -c 'echo 0 > /sys/class/gpio/gpio18/value'
    sleep 1
done

sudo sh -c 'echo 18 > /sys/class/gpio/unexport'

And when I run the "non-sudo" version, I get the error ./Lab1EX4_1.sh: line 4: echo: write error: Device or resource busy

#!/bin/bash

echo "18" > /sys/class/gpio/export

echo "out" > /sys/class/gpio/gpio18/direction

while [ $COUNTER:-1t:10000 ]; do
    echo 1 > /sys/class/gpio/gpio18/value
    sleep 1
    echo 0 > /sys/class/gpio/gpio18/value
    sleep 1
done

echo 18 > /sys/class/gpio/unexport

This has got me so mad...

Thank you peeps! I just want a blinky light :D

I've been trying the past 6 hours to run a very simple LOOKING code. It just turns an LED hooked to pin 18 on and off... This is on a raspberry PI 4.

I've tried using different pins I've tried adding sudo sh -c "..." I've tried single vs. double quotes

When running the following code, I get the error sh: 1: echo: echo: I/O error

#!/bin/bash

sudo sh -c 'echo 18 > /sys/class/gpio/export'

sudo sh -c 'echo "out" > /sys/class/gpio/gpio18/direction'

while [ $COUNTER:-1t:10000 ]; do
    sudo sh -c 'echo 1 > /sys/class/gpio/gpio18/value'
    sleep 1
    sudo sh -c 'echo 0 > /sys/class/gpio/gpio18/value'
    sleep 1
done

sudo sh -c 'echo 18 > /sys/class/gpio/unexport'

And when I run the "non-sudo" version, I get the error ./Lab1EX4_1.sh: line 4: echo: write error: Device or resource busy

#!/bin/bash

echo "18" > /sys/class/gpio/export

echo "out" > /sys/class/gpio/gpio18/direction

while [ $COUNTER:-1t:10000 ]; do
    echo "1" > /sys/class/gpio/gpio18/value
    sleep 1
    echo "0" > /sys/class/gpio/gpio18/value
    sleep 1
done

echo "18" > /sys/class/gpio/unexport

This has got me so mad...

Thank you peeps! I just want a blinky light :D

Source Link
Loading