24b - Comandos y ejemplos de código en Raspberry
Volver al curso
ssh -p 22 pi@192.168.0.31
sudo apt update
sudo apt upgrade -y
sudo apt update && sudo apt upgrade -y
sudo apt install XXXXXXX
nmap -sP 192.168.0.0/24
sudo nmap -sS 192.168.0.21
pwd
cd /
cd
cd ~
ls ls -lhF
cat nano
cat /etc/network/interfaces cat /etc/wpa_supplicant/wpa_supplicant.conf
sudo apt install wiringpi -y
sudo gpio readall
nano scriptblinkbash.sh
chmod a+x scriptblinkbash.sh
sudo ./scriptblinkbash.sh
echo "Encender y apagar el GPIO21 (numeración BCM)"
while true
do
echo "21" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio21/direction
echo "1" > /sys/class/gpio/gpio21/value
sleep 1
echo "0" > /sys/class/gpio/gpio21/value
echo "21" > /sys/class/gpio/unexport
sleep 1
done
nano scriptpushbash.sh
chmod a+x scriptpushbash.sh
sudo ./scriptpushbash.sh
echo "Pulsador en GPIO5 y LED en GPIO17"
echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction
echo "5" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio5/direction
while true; do
read pulsador < /sys/class/gpio/gpio5/value
if [ $(cat "/sys/class/gpio/gpio5/value") -eq 1 ]; then
echo "1" > /sys/class/gpio/gpio17/value
echo "on"
else
echo "0" > /sys/class/gpio/gpio17/value
echo "off"
fi
done
----
nano scriptblinkpython.sh
chmod a+x scriptblinkpython.sh
sudo ./scriptblinkpython.sh
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM) GPIO.setup(21, GPIO.OUT)
print("Encender y apagar el GPIO21 (numeración BCM)")
while True:
GPIO.output(21, True)
time.sleep(1)
GPIO.output(21, False)
time.sleep(1)
nano scriptpushpython.sh
chmod a+x scriptpushpython.sh
sudo ./scriptpushpython.sh
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(3, GPIO.IN)
GPIO.setup(7, GPIO.OUT)
while True:
if GPIO.input(3):
GPIO.output(7, False)
else:
GPIO.output(7, True)
Volver al curso