树莓派开机自启程序实现

前端之家收集整理的这篇文章主要介绍了树莓派开机自启程序实现前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

首先rc.local文件是liunx开机时会自动执行的文件,只要将自己要执行的文件放入其exit 0之前即可被执行。本章将实现树莓派开机时物理引脚12的外接LED灯会闪烁。

1、编写简单的闪灯python脚本:

<p style="margin-left: 60px;">命令:cd dongdd

<p style="margin-left: 60px;">命令:sudo vi startx2.py

<div class="cnblogs_code" style="margin-left: 60px;">

 RPi.GPIO as gp
12 i  range(3):次数
   gp.output(12,10.812,0)输出低电平
   time.sleep(0.8

2、将脚本注册开机启动:

<p style="margin-left: 30px;"><span style="color: #ff0000;"> 命令    内容    #其中&表示后台执行,不会影响主程序执行

       

<p style="margin-left: 30px;">命令:sudo chmod 777  /etc/rc.local

3、重启检查:

<p style="margin-left: 60px;">可观查到结果


<p style="margin-left: 60px;"> 


<p style="margin-left: 60px;"> 


<p style="margin-left: 60px;"> 


<p style="margin-left: 60px;"> 


<p style="margin-left: 60px;"> 


<p style="margin-left: 60px;"> 


<p style="margin-left: 60px;"> 

猜你在找的Linux相关文章