Arduion 驱动 ADXL335三轴加速度计模块

news/2025/2/4 3:53:40/

Arduion 驱动 ADXL335三轴加速度计模块

  • 简介
    • 电气参数
    • 原理图
    • 接线
    • 代码
    • 实验结果

简介

ADXL335是一个小,薄,低功率,完整的三轴加速度计,具有信号调节电压输出。该产品测量加速度的最小全尺度范围为±3 g。它可以测量倾斜传感应用中重力的静态加速度,以及由运动、冲击或振动产生的动态加速度。
在这里插入图片描述

电气参数

供电电源3~5 V
供电电流400uA
通信接口模拟量输出
工作温度-40°~ 85°

原理图

在这里插入图片描述
工作原理:
该传感器是建立在硅晶片上的多晶硅表面微加工结构。多晶硅弹簧使结构悬浮在晶片表面,并提供加速阻力。结构的偏转是用一个差动电容器来测量的,它由独立的固定板和附着在移动质量上的板组成。固定板由180°的失相方波驱动。加速度使移动质量偏转,使差分电容器失衡,导致传感器输出的振幅与加速度成正比。然后使用相敏解调技术来确定加速度的幅度和方向。

接线

ArduionADXL335OLED
5VVCCVCC
GNDGNDGND
A1x-OUT-
A2y-OUT-
A3Z-OUT-
A4-SDA
A5-SCL

代码

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>  //1306的库文件
#define OLED_RESET 13                   //设置复位是13号引脚
Adafruit_SSD1306 display(OLED_RESET);
const int xInput = A1;
const int yInput = A2;
const int zInput = A3;// initialize minimum and maximum Raw Ranges for each axis
int RawMin = 0;
int RawMax = 1023;// Take multiple samples to reduce noise
const int sampleSize = 10;void setup() 
{analogReference(EXTERNAL);Serial.begin(9600);display.begin(SSD1306_SWITCHCAPVCC,0x3C); //刷新display.clearDisplay(); //清屏display.setTextColor(WHITE);   //字体白色display.display();  //显示
}void loop() 
{//Read raw valuesint xRaw = ReadAxis(xInput);int yRaw = ReadAxis(yInput);int zRaw = ReadAxis(zInput);// Convert raw values to 'milli-Gs"long xScaled = map(xRaw, RawMin, RawMax, -3000, 3000);long yScaled = map(yRaw, RawMin, RawMax, -3000, 3000);long zScaled = map(zRaw, RawMin, RawMax, -3000, 3000);// re-scale to fractional Gsfloat xAccel = xScaled / 1000.0;float yAccel = yScaled / 1000.0;float zAccel = zScaled / 1000.0;Serial.print("X, Y, Z:: ");Serial.print(xRaw);Serial.print(", ");Serial.print(yRaw);Serial.print(", ");Serial.print(zRaw);Serial.print(" :: ");Serial.print(xAccel,0);Serial.print("G, ");Serial.print(yAccel,0);Serial.print("G, ");Serial.print(zAccel,0);Serial.println("G"); display.setTextSize(1);       //字体大小为1号display.setCursor(35,0); //字体排布在oled里面的行、列数display.print("ADXL335");display.setCursor(0,12); display.print("X, Y, Z:"); display.print(xRaw);   display.print(", ");display.print(yRaw);display.print(", ");display.print(zRaw);display.setCursor(0,24);display.print("Accel:");          display.print(xAccel,0); display.print(" G");display.print(yAccel,0);display.print(" G");display.print(zAccel,0);display.print(" G");display.display();display.clearDisplay(); delay(200);
}// Take samples and return the average
int ReadAxis(int axisPin)
{long reading = 0;analogRead(axisPin);delay(1);for (int i = 0; i < sampleSize; i++){reading += analogRead(axisPin);}return reading/sampleSize;
}

实验结果

在这里插入图片描述


http://www.ppmy.cn/news/1171994.html

相关文章

QCC 音频输入输出

QCC 音频输入输出 QCC蓝牙芯片&#xff08;QCC3040 QCC3083 QCC3084 QCC5181 等等&#xff09;支持DAC、I2S、SPDIF输出&#xff0c;AUX、I2S、SPDIF、A2DP 输入 蓝牙音频输入&#xff0c;模拟输出是最常见的方式。 也可以再此基础上动态切换输入方式。 输入方式切换参考 sta…

越来越好用的Edge浏览器,盘点Edge浏览器功能丨插件

前些年&#xff0c; Edge 浏览器也宣布加入 Chromium 内核&#xff1b;它的前身是IE浏览器&#xff0c; Edge之所以越来越多人用的一个原因是因为它的内核是Google Chrome的Chromium&#xff0c;而且不需要膜法就可以使用&#xff0c;这一点Chrome浏览器还不行&#xff0c;访问…

普通二维码跳转微信小程序实战

简介 服务端springboot项目,前端基于uniapp的微信小程序,要求扫描二维码之后进入到小程序指定页面,下面记录一下实现过程以及过程中遇到的问题. 实现过程 下面是成功跳转的配置截图: 首先说下二维码规则,这个地方需要填写扫描二维码之后打开的地址,这个地址在我的项目里…

【X3m】DDR压力测试

Index of /downloads/unittest/ 设置CPU模式和降频温度# 若设备重启需再次配置这两条指令 echo performance > /sys/devices/system/cpu/cpufreq/policy0/scaling_governor echo 105000 > /sys/devices/virtual/thermal/thermal_zone0/trip_point_1_temp #1 cpu test ec…

2.2.C++项目:网络版五子棋对战之数据管理模块-数据库的设计

文章目录 一、数据管理模块实现&#xff08;一&#xff09;功能 二、设计&#xff08;一&#xff09;数据库设计&#xff08;二&#xff09;创建user_table类 一、数据管理模块实现 &#xff08;一&#xff09;功能 数据管理模块主要负责对于数据库中数据进行统一的增删改查管…

Pandas pivot - ValueError: Index contains duplicate entries, cannot reshape

pivot&#xff08;&#xff09;报错 在使用pivot()进行长表转宽表时&#xff0c;会出现如下错误&#xff1a; ValueError: Index contains duplicate entries, cannot reshape例&#xff1a; // For an Example df pd.DataFrame({"foo": [one, one, two, two],&q…

网络流探索:解决网络最大流问题的算法集锦

1.初识网络流 网络流一直是初学者心中很难过去的一道坎&#xff0c;很多人说它是一个不像DFS/BFS那么直观的算法&#xff0c;同时网上也有各种参差不齐的材料&#xff0c;让人感到一知半解。 如果你也有这样的感觉&#xff0c;那么不要灰心&#xff0c;坚持住&#xff0c;因为…

递增的三元子序列

给你一个整数数组 nums &#xff0c;判断这个数组中是否存在长度为 3 的递增子序列。 如果存在这样的三元组下标 (i, j, k) 且满足 i < j < k &#xff0c;使得 nums[i] < nums[j] < nums[k] &#xff0c;返回 true &#xff1b;否则&#xff0c;返回 false 。 示…