|
请教各路大神!小弟通过电流转电压模块把4-20mA电流转成0-5V电压,然后通过Arduino的模拟口接受,并把采集的电压在串口监视器上显示。遇到的问题:串口监视器上的接受的电压都为0!!以下是程序代码、模块说明及结果截图,麻烦大神们帮我看看问题出错在哪???
连线的话是电流转电压模块VOUT接Arduino的模拟口A0,模块gnd与板子GND连接(模块要另外24V电源供电)。 - int potPin = A0; //设置模拟口0为sensor的信号输入端口
- long val = 0; //设置val为长整型变量
- float T; //设置电压为浮点型变量
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(potPin,INPUT);
- delay(2000);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- val=analogRead(potPin);
- T = (val/1023*5.00);
- Serial.print("T_sensor= ");
- Serial.print(T);
- Serial.println(" V");
- delay(3000);
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|