这个板子有多少个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 } }
打赏帖 | |
---|---|
VOFA+波形显示+JYD-31蓝牙发送和解析不定长数据被打赏10分 | |
宏定义和const关键字定义被打赏5分 | |
换取逻辑分析仪】STM32G4从入门到大师之五:ADC中断方式单路采集电压被打赏16分 | |
【换取逻辑分析仪】STM32G4从入门到大师之四:ADC查询方式单路采集电压被打赏14分 | |
【分享开发笔记,赚取电动螺丝刀】几个单片机I2S外设的BLCK时钟对比被打赏20分 | |
【功率监测与控制系统DIY活动成果贴】DIY功率计与LabVIEW数据采集被打赏100分 | |
【分享开发笔记,赚取电动螺丝刀】使用ESP32S3调试I2S音频模块MAX98357被打赏22分 | |
【Freertos】任务管理被打赏10分 | |
分享博世的两种不同的喷射系统模式被打赏5分 | |
汽车+开路实验与短路实验被打赏10分 |