资源简介
来自GitHub分享的arduino库函数合集
支持多种传感器和相应硬件
包含例程
仅供交流学习之用!
代码片段和文件信息
//
// FILE: AD524X.cpp
// AUTHOR: Rob Tillaart
// VERSION: see AD524X.h file
// PURPOSE: I2C digital potentiometer AD5241 AD5242
// DATE: 2013-10-12
// URL:
//
// Released to the public domain
//
#include “AD524X.h“
#define AS524X_RDAC0 0x00
#define AS524X_RDAC1 0x80
#define AS524X_RESET 0x40
#define AS524X_SHUTDOWN 0x20
#define AS524X_O1_HIGH 0x10
#define AS524X_O2_HIGH 0x08
AD524X::AD524X(const uint8_t address)
{
// address: 0x01011xx = 0x2C - 0x2F
_address = address;
_lastValue[0] = _lastValue[1] = 127; // power on reset => mid position
_O1 = _O2 = 0;
}
uint8_t AD524X::zeroAll()
{
write(0 0 LOW LOW);
return write(1 0);
}
uint8_t AD524X::write(const uint8_t rdac const uint8_t value)
{
if (rdac > 1) return AS524X_ERROR;
uint8_t cmd = (rdac == 0) ? AS524X_RDAC0 : AS524X_RDAC1;
// apply the output lines
cmd = cmd | _O1 | _O2;
_lastValue[rdac] = value;
return send(cmd value);
}
uint8_t AD524X::write(const uint8_t rdac const uint8_t value const uint8_t O1 const uint8_t O2)
{
if (rdac > 1) return AS524X_ERROR;
uint8_t cmd = (rdac == 0) ? AS524X_RDAC0 : AS524X_RDAC1;
_O1 = (O1 == LOW) ? 0 : AS524X_O1_HIGH;
_O2 = (O2 == LOW) ? 0 : AS524X_O2_HIGH;
// apply the output lines
cmd = cmd | _O1 | _O2;
_lastValue[rdac] = value;
return send(cmd value);
}
uint8_t AD524X::setO1(const uint8_t value)
{
_O1 = (value == LOW) ? 0 : AS524X_O1_HIGH;
uint8_t cmd = AS524X_RDAC0 | _O1 | _O2;
return send(cmd _lastValue[0]);
}
uint8_t AD524X::setO2(const uint8_t value)
{
_O2 = (value == LOW) ? 0: AS524X_O2_HIGH;
uint8_t cmd = AS524X_RDAC0 | _O1 | _O2;
return send(cmd _lastValue[0]);
}
uint8_t AD524X::getO1()
{
return (_O1 > 0);
}
uint8_t AD524X::getO2()
{
return (_O2 > 0);
}
uint8_t AD524X::read(const uint8_t rdac)
{
return _lastValue[rdac];
}
uint8_t AD524X::readBackRegister()
{
Wire.beginTransmission(_address);
Wire.endTransmission();
Wire.requestFrom(_address (uint8_t)1);
return Wire.read();
}
uint8_t AD524X::midScaleReset(const uint8_t rdac)
{
if (rdac > 1) return AS524X_ERROR;
uint8_t cmd = AS524X_RESET;
if (rdac == 1) cmd |= AS524X_RDAC1;
cmd = cmd | _O1 | _O2;
_lastValue[rdac] = 127;
return send(cmd _lastValue[rdac]);
}
// TODO read datasheet
// uint8_t AD524X::shutDown()
// {
// uint8_t cmd = AS524X_SHUTDOWN;
// sendCommand(cmd 0)
// }
//////////////////////////////////////////////////////////
//
// PRIVATE
//
uint8_t AD524X::send(const uint8_t cmd const uint8_t value)
{
Wire.beginTransmission(_address);
Wire.write(cmd);
Wire.write(value);
return Wire.endTransmission();
}
// -- END OF FILE --
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 2274 2018-09-02 07:26 sketches\DHT_Simulator\DHT_Simulator.ino
....... 4421 2018-09-02 07:26 sketches\fastHaverSine\fastHaverSine.ino
....... 7712 2018-09-02 07:26 sketches\MultiSpeedI2CScanner\MultiSpeedI2CScanner.ino
....... 804 2018-09-02 07:26 sketches\MultiSpeedI2CScanner\readme.md
....... 957 2018-09-02 07:26 sketches\MultiSpeedI2CScanner\releaseNotes.txt
....... 1793 2018-09-02 07:26 sketches\oneWireSearch\oneWireSearch.ino
....... 1074 2018-09-02 07:26 LICENSE.md
....... 1342 2018-09-02 07:26 README.md
....... 2747 2018-09-02 07:26 libraries\AD524X\AD524X.cpp
....... 1269 2018-09-02 07:26 libraries\AD524X\AD524X.h
....... 731 2018-09-02 07:26 libraries\AD524X\examples\AD524X_followA0\AD524X_followA0.ino
....... 708 2018-09-02 07:26 libraries\AD524X\examples\AD524X_midScaleReset\AD524X_midScaleReset.ino
....... 650 2018-09-02 07:26 libraries\AD524X\examples\AD524X_read\AD524X_read.ino
....... 916 2018-09-02 07:26 libraries\AD524X\examples\AD524X_readBackRegister\AD524X_readBackRegister.ino
....... 554 2018-09-02 07:26 libraries\AD524X\examples\AD524X_sawtooth\AD524X_sawtooth.ino
....... 762 2018-09-02 07:26 libraries\AD524X\examples\AD524X_setO\AD524X_setO.ino
....... 685 2018-09-02 07:26 libraries\AD524X\examples\AD524X_write\AD524X_write.ino
....... 508 2018-09-02 07:26 libraries\AD524X\library.json
....... 340 2018-09-02 07:26 libraries\AD524X\library.properties
....... 5711 2018-09-02 07:26 libraries\AM232X\AM232X.cpp
....... 1580 2018-09-02 07:26 libraries\AM232X\AM232X.h
....... 960 2018-09-02 07:26 libraries\AM232X\examples\AM2320\AM2320.ino
....... 1909 2018-09-02 07:26 libraries\AM232X\examples\AM2320_test\AM2320_test.ino
....... 953 2018-09-02 07:26 libraries\AM232X\examples\AM2322\AM2322.ino
....... 812 2018-09-02 07:26 libraries\AM232X\keywords.txt
....... 496 2018-09-02 07:26 libraries\AM232X\library.json
....... 306 2018-09-02 07:26 libraries\AM232X\library.properties
....... 1063 2018-09-02 07:26 libraries\AnalogPin\AnalogPin.cpp
....... 658 2018-09-02 07:26 libraries\AnalogPin\AnalogPin.h
....... 592 2018-09-02 07:26 libraries\AnalogPin\examples\AnalogPin\AnalogPin.ino
............此处省略677个文件信息
相关资源
- 最全Linux C 库函数官方中文API手册
- arduino JSON数据格式库
- proteus arduino仿真库
- arduino 多个程序一起工作程序
- arduino蜂鸣器和光控灯实验报告
- Arduino自动浇花系统_一路继电器控制水
- Arduino小车控制程序含遥控+寻迹+避障
- TM1637显示器arduino库文件
- arduino rfid库函数
- 基于arduino的循迹小车不含有PID算法
- 基于arduino的循迹小车含有PID算法
- 基于arduino的无线温湿度传输系统
- Arduino多任务同时进行.rar
- arduino 机械臂 画圆程序 通过Arduino控制
- PS2+ arduino+接线图+源码
- CH340G-CH340通用驱动 支持win10/win7 64位驱
- 智能小车黑线循迹&超声波避障综合实
- STM32的ADC模数转换(库函数),亲测可
- arduino光电编码器程序
- STM32F103ZET6库函数模板
- Arduino智能鱼缸
- STM32库函数
- arduino pid循迹代码.zip
- Arduino红外传感器库文件
- DHT11库文件和
- arduino pid 调节 平衡小车代码
- Arduino全地形小车代码
- Arduino红外循迹小车
- 基于Arduino的温湿度系统设计
- In-Sight速查库函数.pdf
评论
共有 条评论