这个板子有多少个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
}
}
| 有奖活动 | |
|---|---|
| 硬核工程师专属补给计划——填盲盒 | |
| “我踩过的那些坑”主题活动——第002期 | |
| 【EEPW电子工程师创研计划】技术变现通道已开启~ | |
| 发原创文章 【每月瓜分千元赏金 凭实力攒钱买好礼~】 | |
| 【EEPW在线】E起听工程师的声音! | |
| 高校联络员开始招募啦!有惊喜!! | |
| 【工程师专属福利】每天30秒,积分轻松拿!EEPW宠粉打卡计划启动! | |
| 送您一块开发板,2025年“我要开发板活动”又开始了! | |