小白求助,倾斜传感器ADXL335装在esp8266 ESP8266 V3 12N F后,xyz为什么出错

LKM恶魔控 2020-10-03 05:12:00

#define xPin 4
#define yPin 0
#define zPin 2

int sampleDelay=500;
void setup() {
Serial.begin(9600);

pinMode(xPin,INPUT);
pinMode(yPin,INPUT);
pinMode(zPin,INPUT);
}

void loop() {
int x=analogRead(xPin);
delay(1);
int y=analogRead(yPin);
delay(1);
int z=analogRead(zPin);
delay(1);
float zero_G=512.0;
float scale=102.3;
Serial.print(((float)x-zero_G)/scale);
Serial.print("\t");
Serial.print(((float)y-zero_G)/scale);
Serial.print("\t");
Serial.print(((float)z-zero_G)/scale);
Serial.print("\n");
delay(sampleDelay);

}


...全文
2066 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

2,302

社区成员

发帖
与我相关
我的任务
社区描述
硬件使用 电脑整机及配件
社区管理员
  • 电脑整机及配件社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧