这个板子有多少个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网站征稿正在进行时,欢迎踊跃投稿啦 | |
【有奖活动】智能可穿戴设备AR/VR如何引领科技新潮流! | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
【有奖活动】震撼来袭!这场直播将直击工程师的心灵! |
打赏帖 | |
---|---|
如何实现基于NXPiMX.RT1021的BH1730采集被打赏50分 | |
【换取手持数字示波器】AHT10温度检测分享被打赏40分 | |
【换取手持数字示波器】ACM32F070开发板点亮LCD屏和触控按键,串口,ADC被打赏40分 | |
【换取手持数字示波器】ACM32F070LCD屏和触控按键功驱动蜂鸣器分享被打赏40分 | |
【换取手持数字示波器】国民技术PWM功能知识分享被打赏40分 | |
【换取手持数字示波器】放大器运放知识分享被打赏40分 | |
【分享评测,赢取加热台】+开关电源AC输入知识分享被打赏30分 | |
【换取手持数字示波器】N32G430点亮数码管与串口打印、ADC被打赏40分 | |
老胖子聊电路--分析一个反馈电路被打赏50分 | |
【换取手持数字示波器】+点亮WS2812RGB灯被打赏50分 |