using Bash script to control LED with WiringPi on Raspberry Pi
来源:互联网 发布:java 时间格式有几种 编辑:程序博客网 时间:2024/06/05 02:34
Before programming in bash
You need is to install WiringPi first.
Click here for information of installing WiringPi on Raspberry Pi.
SInce bash is already installed on most Linux destros. we just need to move on.
Prepare Circuit
Like what I did before, the short leg of LED light is connect to the GND of the pin pool of Raspberry Pi board.
And I used a 4.7K resistor to connect with between the GPIO 18 and the long leg of the LED light.
Write a bash script
vim blink.sh
then we need to write these down:
gpio -g mode 18 out #set pin 18 mode outgpio -g write 18 1 #set pin 18 onwhile true; do gpio -g write 18 0 #LED light off echo LED light is off sleep 1 gpio -g write 18 1 #LED light on echo LED light is on sleep 1done
This script includes an infinite loop.
Make the shell script executable
chmod +x blink.sh
Run the script
./blink.sh
You will see:
pi@raspberrypi ~/songhua $ ./blink.sh LED light is offLED light is onLED light is offLED light is onLED light is offLED light is onLED light is offLED light is onLED light is offLED light is onLED light is offLED light is onLED light is offLED light is onLED light is offLED light is on^Cpi@raspberrypi ~/songhua $
using " CTRL + C " for key interrupt to terminate the present processl
Please inform the author or declare the original link of this page when you share with others.
- using Bash script to control LED with WiringPi on Raspberry Pi
- raspberry Pi on Archlinux, Install wiringPi , GPIO
- chmod 777 wiringpi.ini to control LED on Linux
- Raspberry Pi 2 ubuntu wiringPi GPIO点亮LED
- On Raspberry Pi , Using Raspbian to install LNMP
- Raspberry Pi GPIO with Python (A WiringPi wrapper :D)
- Raspberry Pi: Use ssh to talk with your Raspberry Pi
- Sound configuration on Raspberry Pi with ALSA
- Navigating with Navit on the Raspberry Pi
- How to Control a Lamp With Voice Commands and a Raspberry Pi
- How to config WIFI on Raspberry PI
- Raspberry Pi Blink--NO delay(WiringPi)
- Raspberry Pi controls Arduino Board with PHP, Bash and HTML
- 【raspberry pi】server assistant to shutdown and reboot raspberry pi using mobile app
- Node.js installation with nvm on Raspberry pi
- Trajectory following with MAVROS OFFBOARD on Raspberry Pi
- ROS Tutorials to Start Working with Arduino and Raspberry Pi
- How to Setup RaspBerry Pi with RASPBIAN STRETCH LITE
- JS调用后台方法大全
- 云计算技术的产生、概念、原理
- [C++]数据结构:排序算法Part2----快速排序、归并排序、箱子排序、基数排序
- 突然想放弃 visual studio ..
- ExtJs智能提示设置
- using Bash script to control LED with WiringPi on Raspberry Pi
- 推荐系统
- GPIO模拟I2C程序实现
- hdu 2037贪心
- codeforces 224A
- jQuery 操作Cookie
- Android 混淆打包编译
- soj 1754. 逃离洞穴
- c++对map按照value排序