zoukankan      html  css  js  c++  java
  • 继电器srd05vdcslc

     

     具体 接线 如下图所示

     

    查看  gpio如果 无此命令,可以安装 wiringpi.

    root@raspberrypi:/setup# gpio redall

    -bash: gpio: command not found 

    apt install wiringpi 

    root@raspberrypi:/setup# gpio readall 

    如上面图片所示,把 引脚40 的BCM为21

    gpio readall  #列出所有针角

    gpio mode 29 out  #设置[以writePi编号为29]的GPIO(即GPIO29口) 口为输出模式

    gpio read 29  #获取当前GPIO29口的电平(0或1)

    gpio write 29 1   #设置当前GPIO29口的电平为1(1为高电平电源开启,)

    gpio write 29 0   #设置当前GPIO29口的电平为0(0为低电平电源关闭)

    python3 脚本 ,5秒开,5秒关

    ----------------------------

    #!/usr/bin/python

    #encoding:utf-8

    import RPi.GPIO

    import time

    time_out = 5

    RELAY = 21

    RPi.GPIO.setmode(RPi.GPIO.BCM)

    RPi.GPIO.setup(RELAY,RPi.GPIO.OUT)

    try:

       while True:

         RPi.GPIO.output(RELAY,RPi.GPIO.HIGH)

         time.sleep(time_out)

         RPi.GPIO.output(RELAY,RPi.GPIO.LOW)

         time.sleep(time_out)

        

    except KeyboardInterrupt:

       pass

    RPi.GPIO.cleanup()

    ----------------------------

     

  • 相关阅读:
    1697 ⑨要写信
    1220 数字三角形
    4979 数塔
    bzoj1618[Usaco2008 Nov]Buying Hay 购买干草
    bzoj1066[SCOI2007]蜥蜴
    bzoj1008[HNOI2008]越狱
    cf437D The Child and Zoo
    cf437C The Child and Toy
    cf437B The Child and Set
    cf437A The Child and Homework
  • 原文地址:https://www.cnblogs.com/likehc/p/15679566.html
Copyright © 2011-2022 走看看