这个板子有多少个ADC不太清楚,或者可以查datasheet吧,暂时用不了辣么多,先用arduino的吧,
找出了一个遥杆,分别连接到了A1\A2和D7
老规矩记录代码,真怕什么时候mbed崩了
#include "mbed.h"
AnalogIn analog_value1(A0);
AnalogIn analog_value2(A1);
DigitalIn mybutton(D7);
DigitalOut led(LED1);
int main() {
float meas1,meas2;
int key;
printf("\nAnalogIn example\n");
while(1) {
meas1 = analog_value1.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
meas1 = meas1 * 3300; // Change the value to be in the 0 to 3300 range
meas2 = analog_value2.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
meas2 = meas2 * 3300; // Change the value to be in the 0 to 3300 range
key = mybutton.read();
printf("measure = %.0f mV, %.0f mV, %d\n", meas1, meas2, key);
if (meas1 > 2000) { // If the value is greater than 2V then switch the LED on
led = 1;
}
else {
led = 0;
}
wait(0.2); // 200 ms
}
}
我要赚赏金打赏帖 |
|
|---|---|
| 设备功耗web监控界面(ESP32C5)被打赏¥28元 | |
| OrangePiZero2W系统被打赏¥33元 | |
| Linux环境下以模拟方式快速实现出入管理功能测试被打赏¥24元 | |
| 树莓派3+Klipper,老3D打印机满血升级被打赏¥33元 | |
| OK1126B-S开发板下串口屏及其应用被打赏¥21元 | |
| 低功耗超声波液位测距仪(ESP32S3)被打赏¥27元 | |
| 在K230DBOX上实现多时段语音提示功能被打赏¥14元 | |
| 使K230DBOX实现相机持续拍照功能被打赏¥12元 | |
| 基于K230DBOX的文本管理器设计被打赏¥14元 | |
| 基于K230DBOX的彩色画板功能实现被打赏¥15元 | |