这个板子有多少个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 } }
有奖活动 | |
---|---|
发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
【EEPW在线】E起听工程师的声音! | |
“我踩过的那些坑”主题活动——第001期 | |
高校联络员开始招募啦!有惊喜!! | |
【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
送您一块开发板,2025年“我要开发板活动”又开始了! | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
【我踩过的那些坑】电感选型错误导致的处理器连接不上被打赏50分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏10分 | |
【我踩过的那些坑】DRC使用位置错误导致的问题被打赏100分 | |
我踩过的那些坑之混合OTL功放与落地音箱被打赏50分 | |
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 |