|
请教各位大神一个问题:
电压表测得光纤传感器的输出值为5.05V,接在arduino上,串口显示的却是没有规律的跳变数字,arduino程序和外部接口应该没有问题,因为我用一颗电池做试验,测得1.58V,而电压表测得1.60V,误差可忽略,外部A0和GND之间接了一个100K的下拉电阻,既然程序和外部电路没问题,光纤传感器输出也没问题,那么为什么把光纤传感器接在A0上就不行了呢?
arduino代码如下: - int sensorValue = 0;
- float float_sensorValue = 0;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600);
- }
- void loop() {
- // put your main code here, to run repeatedly:
- sensorValue = analogRead(A0);
- float_sensorValue = (float)sensorValue/1023*5.00;
- Serial.print(float_sensorValue,2);
- Serial.print('\n');
- delay(1000);
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|