1. Use of script
First, you need to install his GPIO access library on the Raspberry Pi by accessing the system with SSH or opening a terminal:
cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb sudo dpkg -i wiringpi-latest.deb |
Waiting to download and install WireingPi:
sudo dpkg -i wiringpi-latest.deb |
Check out Gpio:
gpio -v |
2. Create a text document
Then create a text document in your home directory and copy the contents of fan.sh:
|
cd ~ |
nano fan.sh |
Paste the script and save it with CTRL+X. When we exit the editor, we'll give the script execution permissions with:
sudo chmod +x fan.sh |
Now the script is ready to be used. But we'll need run it manually every time the computer is started. To solve this we'll use a Linux daemon called Cron:
crontab -e |
Paste the next line at the end of the file where there is no #:
@reboot /bin/bash /home/pi/fan.sh > /dev/null 2>&1 |
Save it with CTRL+X and exit.
Now the script is scheduled. To execute it we need to restart and it'll start running in the background.
sudo reboot |