1 Star 0 Fork 0

DFRobot/DFRobot_RaspberryPi_Expansion_Board

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

DFRobot IO expansion HAT for Pi

这款树莓派扩展板通过I2C和树莓派通信,它扩展了10个GPIO引脚,1个SPI接口,4个IIC接口、1个UART接口, 和4个12位ADC接口,且各扩展接口样式完全兼容DFRobot的Gravity接口。

产品效果图

产品链接(https://www.dfrobot.com.cn/goods-2041.html

SKU: DFR0566

目录

概述

这是一个树莓派外设扩展板库,它具有以下特点:

  1. 读取12位ADC值。
  2. 设置PWM的频率和占空比。
  3. 驱动数字RGB灯。
  4. 驱动180度伺服电机

库安装

  1. 下载库至树莓派,要使用这个库,首先要将库下载到Raspberry Pi,命令下载方法如下:
sudo git clone https://github.com/DFRobot/DFRobot_RaspberryPi_Expansion_Board
  1. 打开并运行例程,要执行一个例程demo_x.py,请在命令行中输入python demo_x.py。例如,要执行demo_adc.py 例程,你需要输入:
python demo_adc.py 

方法

  '''!
    @brief    树莓派扩展板初始化
    @return   扩展板状态
  '''
  def begin(self):
    
  '''!
    @brief    设置树莓派扩展板的IIC通信地址,改地址重启生效
    @param address:    IIC地址,范围1~127
  '''
  def set_addr(self, addr):
    
  '''!
    @brief    使能PWM功能,使用该功能需给扩展板外部供电。
  '''
  def set_pwm_enable(self):
    
  '''!
    @brief  失能PWM
  '''
  def set_pwm_disable(self):
    
  '''!
    @brief    设置pwm频率
    @param freq: PWM频率,范围 1 - 1000
  '''
  def set_pwm_frequency(self, freq):
    
  '''!
    @brief    设置PWM通道和占空比。
    @param chan: 列表类型     1个或多个通道集合,可以是1~4或ALL,即所有通道
    @param duty: 浮点类型    占空比,范围 0.0 ~ 100.0
  '''
  def set_pwm_duty(self, chan, duty):
    
  '''!
    @brief  使能ADC功能。
  '''
  def set_adc_enable(self):
    
  '''!
    @brief    失能ADC功能。
  '''
  def set_adc_disable(self):
    
  '''!
    @brief    获取ADC的值
    @param chan: int类型    单个通道或多个通道集合,范围1~4或ALL,即所有通道
    @return :list类型       通道ADC列表
  '''
  def get_adc_value(self, chan):
    
  '''!
    @brief    如果你忘记了树莓派扩展本的地址,你可以调用这个函数来检测该地址
    @return   地址列表
  '''
  def detecte(self):
    

class DFRobot_Epansion_Board_Digital_RGB_LED():
  '''!
    @param board: DFRobot_Expansion_Board   操作数字rgb灯的实例,测试灯的链接: https://www.dfrobot.com/product-1829.html
    @note 这款LED必须必须连接到PWM通道引脚上。 
  '''
  def __init__(self, board):
    
  '''!
    @brief    设置数字RGB LED颜色通道,这些参数不能重复
    @param chan_r: int    设置红色分量通道,范围1~4
    @param chan_g: int    设置绿色分量通道,范围1~4
    @param chan_b: int    设置蓝色分量通道,范围1~4
  '''
  def begin(self, chan_r, chan_g, chan_b):
    
  '''!
    @brief    设置LED的RGB888格式颜色
    @param r: int   颜色红色分量
    @param g: int   颜色绿色分量
    @param b: int   颜色蓝色分量
  '''
  def color888(self, r, g, b):
    
  '''!
    @brief   设置24位颜色显示
    @param color: int   24位颜色
  '''
  def color24(self, color):
    
  '''!
    @brief    设置18位颜色
    @param color: int   16位颜色
  '''
  def color565(self, color):
    

class DFRobot_Expansion_Board_Servo():
  '''!
    @param board: DFRobot_Expansion_Board   操作伺服电机实例,测试所用伺服电机的链接: https://www.dfrobot.com/product-255.html
    @note 伺服电机必须连接到pwm通道
  '''
  def __init__(self, board):
    
  '''!
    @brief    初始化
  '''
  def begin(self):
    
  '''!
    @brief    伺服电机移动 move
    @param id: list     单个通道或多个通道集合,范围1~4或ALL,即所有通道
    @param angle: int   转动角度,范围0~180度
  '''
  def move(self, id, angle):
    

class DFRobot_Expansion_Board_IIC(DFRobot_Expansion_Board):
  '''!
    @param bus_id: int   树莓派的IIC总线id
    @oaram addr: int     树莓派扩展板IIC地址
  '''
  def __init__(self, bus_id, addr):

兼容性

主板 通过 未通过 未测试 备注
RaspberryPi2
RaspberryPi3
RaspberryPi4
  • Python 版本
Python 通过 未通过 未测试 备注
Python2
Python3

历史

  • 2019/03/28 - 1.0.0 版本

创作者

Written by Frank(jiehan.guo@dfrobot.com), 2021. (Welcome to our website)

Copyright 2010 DFRobot Co.Ltd Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/dfrobot/DFRobot_RaspberryPi_Expansion_Board.git
git@gitee.com:dfrobot/DFRobot_RaspberryPi_Expansion_Board.git
dfrobot
DFRobot_RaspberryPi_Expansion_Board
DFRobot_RaspberryPi_Expansion_Board
master

搜索帮助