• 已解决 73482 个问题
  • 已帮助 5993 位优秀工程师

为什么我的UNO模拟端口在0输入时会产生一个正弦信号?

快雪时晴 2015-12-02 浏览量:1994
为什么我的UNO模拟端口在0输入时会产生一个正弦信号?我要如何将端口清零以便正确的读取模拟输入电压?求大神解答。
0 0 收起

我来回答

上传资料:
选择文件 文件大小不超过15M(格式支持:doc、ppt、xls、pdf、zip、rar、txt)
最佳答案
  • 一般配置为模拟输入的引脚,在未接入被测信号时,引脚电压是不确定的,所以单独去测量是不正确的,你只有再接入采集信号,才能得到正确的电压值,如果想采集0V,接地就可以看到
    • 发布于 2015-12-02
    • 举报
    • 评论 0
    • 0
    • 0

其他答案 数量:7
  • 哪个地方产生正弦信号?把图和程序发上来看看。
    • 发布于2015-12-02
    • 举报
    • 评论 0
    • 0
    • 0

  • const int sigin = 2;
    const int ledPin = 2; // the pin that the LED is attached to
    int sig_sensor;
    int sig_close;
    
    void setup()
    {
    Serial.begin(9600); //initialisation of the port
    pinMode(sigin, INPUT);
    pinMode(ledPin, OUTPUT);
    }
    
    
    
    void loop()
    {
    
    
    sig_sensor = analogRead(sigin);
    Serial.write(sig_sensor); //sending of the number
    delay(50); //wait 0.1 second
    
    
    // read the most recent byte (which will be from 0 to 255):
    // check if data has been sent from the computer:
    if (Serial.available()) {
    sig_close = Serial.read();
    
    //sigout = map(sig_close,-50,50,-512,512);
    
    // set the brightness of the LED:
    digitalWrite(ledPin, sig_close);
    //delay(5000);
    //digitalWrite(ledPin, 0);
    
    } 
    }
    
    • 发布于2015-12-02
    • 举报
    • 评论 0
    • 0
    • 0

  • 代码在楼下,我定义模拟输入脚是A2,但是我什么输入都不接A2就有一个自动的正弦信号啊。。。
    • 发布于2015-12-02
    • 举报
    • 评论 0
    • 0
    • 0

  • const int sigin = 2;
    const int ledPin = 2; // the pin that the LED is attached to
    int sig_sensor;
    int sig_close;
    
    void setup()
    {
    Serial.begin(9600); //initialisation of the port
    pinMode(sigin, INPUT);
    pinMode(ledPin, OUTPUT);
    }
    
    
    
    void loop()
    {
    
    
    sig_sensor = analogRead(sigin);
    Serial.write(sig_sensor); //sending of the number
    delay(50); //wait 0.1 second
    
    
    // read the most recent byte (which will be from 0 to 255):
    // check if data has been sent from the computer:
    if (Serial.available()) {
    sig_close = Serial.read();
    
    //sigout = map(sig_close,-50,50,-512,512);
    
    // set the brightness of the LED:
    digitalWrite(ledPin, sig_close);
    //delay(5000);
    //digitalWrite(ledPin, 0);
    
    } 
    }
    
    • 发布于2015-12-02
    • 举报
    • 评论 0
    • 0
    • 0

  • 这个图前一部分我什么都没接,后面我给输入接了一个0v

    • 发布于2015-12-02
    • 举报
    • 评论 0
    • 0
    • 0

  • 这个不是产生正弦波,引脚悬空的话,电压是浮动的;

    实际应用中,读取模拟电压,引脚也不会是处于悬空的状态。试试串个电阻接地,再测模拟输入电压。

    • 发布于2015-12-02
    • 举报
    • 评论 0
    • 0
    • 0

相关问题

问题达人换一批

为什么我的UNO模拟端口在0输入时会产生一个正弦信号?