Arduino:1.8.19 (Windows 10), 开发板:"Arduino Uno"
C:\Users\Ding\Desktop\Arduino\___\___.ino: In function 'void FANUP()':
___:51:3: error: 'QCA' was not declared in this scope
QCA();
^~~
C:\Users\Ding\Desktop\Arduino\___\___.ino: In function 'void SHARKUP()':
___:69:3: error: 'QCB' was not declared in this scope
QCB();
^~~
___:72:1: error: a function-definition is not allowed here before '{' token
{
^
___:78:1: error: a function-definition is not allowed here before '{' token
{
^
___:82:1: error: expected '}' at end of input
}
^
exit status 1
'QCA' was not declared in this scope
程序系芥羊弟:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
Servo myservo;
LiquidCrystal_I2C mylcd(0x3F ,16,2);
int pos=0;
int at1=7;
int at2=6;
int at3=5;
int at4=4;
int beep=8;
int aj1;
int aj2;
int aj3;
int aj4;
void setup()
{
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(2, OUTPUT);
pinMode(at1, INPUT);
pinMode(at2, INPUT);
pinMode(at3, INPUT);
pinMode(at4, INPUT);
mylcd.init();
mylcd.backlight();
myservo.attach(3);
mylcd.setCursor(0, 0);
mylcd.print("fan off ");
mylcd.setCursor(0, 1);
mylcd.print("shark off");
}
void loop()
{
aj1=digitalRead(at1);
aj2=digitalRead(at2);
aj3=digitalRead(at3);
aj4=digitalRead(at4);
if(aj1==LOW)FANUP();
if(aj3==LOW)SHARKUP();
}
void FANUP()
{
while(digitalRead(aj2)==1)
{
mylcd.setCursor(0, 0);
mylcd.print("fan up ");
digitalWrite(2,LOW);
}
QCA();
}
void SHARKUP()
{
while(digitalRead(aj4)==1)
{
mylcd.setCursor(0, 0);
mylcd.print("shark up ");
for (pos = 0; pos < 180; pos += 1)
{
myservo.write(pos);
delay(100);
}
for (pos = 180; pos >= 1; pos -= 1)
{
myservo.write(pos);
delay(15);
}
QCB();
}
void QCA()
{
mylcd.setCursor(0, 0);
mylcd.print("fan off ");
digitalWrite(2,HIGH);
}
void QCB()
{
mylcd.setCursor(0, 0);
mylcd.print("shark off ");
myservo.write(0)
}
标注红色的是错误行,我严重怀疑橙色行也错了。
模仿的是抢答器代码如下
int redled=8; //红色LED 输出
int yellowled=7; //黄色LED输出
int greenled=6; //绿色LED输出
int redpin=5; //红色按键引脚
int yellowpin=4; //黄色按键引脚
int greenpin=3; //绿色按键引脚
int restpin=2; //复位按键引脚定义
int red;
int yellow;
int green;
void setup()
{
pinMode(redled,OUTPUT);
pinMode(yellowled,OUTPUT);
pinMode(greenled,OUTPUT);
pinMode(redpin,INPUT);
pinMode(yellowpin,INPUT);
pinMode(greenpin,INPUT);
}
void loop() //按键循环扫描
{
red=digitalRead(redpin);
yellow=digitalRead(yellowpin);
green=digitalRead(greenpin);
if(red==LOW)RED_YES();
if(yellow==LOW)YELLOW_YES();
if(green==LOW)GREEN_YES();
}
void RED_YES()//一直执行红灯亮,直到复位键按下,结束循环
{
while(digitalRead(restpin)==1)
{
digitalWrite(redled,HIGH);
digitalWrite(greenled,LOW);
digitalWrite(yellowled,LOW);
}
clear_led();
}
void YELLOW_YES()//一直执行黄灯亮,直到复位键按下,结束循环
{
while(digitalRead(restpin)==1)
{
digitalWrite(redled,LOW);
digitalWrite(greenled,LOW);
digitalWrite(yellowled,HIGH);
}
clear_led();
}
void GREEN_YES()//一直执行绿灯亮,直到复位键按下,结束循环
{
while(digitalRead(restpin)==1)
{
digitalWrite(redled,LOW);
digitalWrite(greenled,HIGH);
digitalWrite(yellowled,LOW);
}
clear_led();
}
void clear_led()//清除LED
{
digitalWrite(redled,LOW);
digitalWrite(greenled,LOW);
digitalWrite(yellowled,LOW);
}
各位大神师兄们,谁看得懂啊???
在线等待回答,急得要命啊!!!
感谢各位父老乡亲们!!!!!!!!!!