知秋一玥
2022-04-02 15:29
采纳率: 100%
浏览 54

Vscode编程arduino函数时候报错,但是在arduinoIDE中却可以编译,如何解决?

Vscode编程arduino,定义了Clear函数时候报错,报错内容如下

img

源程序如下
#include <Arduino.h>
void setup() {
  int pinNumber = 3;
  while(pinNumber <= 9){
    pinMode(pinNumber, OUTPUT);
    pinNumber = pinNumber + 1;
  }
}

// the loop function runs over and over again forever
void loop() {
  int myNumber = random(0, 4);
  switch(myNumber) { 
    case 1: //显示1
      digitalWrite(4, HIGH);
      digitalWrite(7, HIGH); 
      break;   
    case 2: //显示2
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH); 
      digitalWrite(5, HIGH); 
      digitalWrite(8, HIGH); 
      digitalWrite(9, HIGH); 
      break;   
    case 3: //显示3
      digitalWrite(3, HIGH);
      digitalWrite(4, HIGH); 
      digitalWrite(5, HIGH); 
      digitalWrite(7, HIGH); 
      digitalWrite(8, HIGH); 
      break;   
    default:
        digitalWrite(4, HIGH); 
        digitalWrite(5, HIGH); 
        digitalWrite(7, HIGH); 
        digitalWrite(8, HIGH);  
        digitalWrite(9, HIGH);
  }
  delay(500);
  Clear();        //调用函数
  delay(500);  
}
void Clear() {  //定义函数清理显示内容
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW); 
  digitalWrite(6, LOW); 
  digitalWrite(7, LOW); 
  digitalWrite(8, LOW); 
  digitalWrite(9, LOW); 
}


运行结果及报错内容

img

请问这是怎么一回事呢?

2条回答 默认 最新

相关推荐 更多相似问题