|
在arduino编写红外遥控调速小风扇的程序,代码如下:- #include<IRremote.h>
- #include<Servo.h>
- boolean a = false;
- int b = 255;
- void setup(){
- Servo myServo;
- myServo.attach(9);
- myServo.write(90);
- IRrecv IRRecv(12);
- decode_results results;
- IRRecv.enableIRIn();
- Serial.begin(9600);
- }
- void loop(){
- if(IRRecv.decode(&results))
- {
- Serial.println(results.value,HEX);
- switch(results.value){
- case 0xFFC23D:{
- if (a == false){
- a = true;
- }
- else{
- a = false;
- }
- }
- break;
- case 0xFF22DD:{
- b = b - 5;
- if (b <= 50){
- b = 50;
- }
- }
- break;
- case 0xFF02FD:{
- b = b + 5;
- if(b >= 255){
- b = 255;
- }
- }
- break;
- case 0xFFE01F:{
- myServo.write(180);
- }
- break;
- case 0xFFA857:{
- myServo.write(0);
- }
- }
- if(a == false){
- analogWrite(11,b);
- analogWrite(3,0);
- }
- else{
- analogWrite(11,0);
- analogWrite(3,0);
- }
- IRRecv.resume();
- }
- }
复制代码 可是出现了如下错误:
'IRRecv' was not declared in this scope
在浏览器上一翻译,中文是:
'irRecv'不在这个范围内声明
这是怎么回事?
|
|