当我尝试在Arduino IDE中编译此代码时,我收到一个错误:"请求成员' concat'在'内容',这是非类型' char'"
任何人都可以帮我吗?提前谢谢!
//Schematic: irled on pin 13 with a resistor that simple
#include <IRremote.h>
IRsend irsend;
char content = ' ';
char character;
// Raw codes for buttons of Samsung remote control BN5900706A
unsigned int buttonPower[68] = {4500, 4450, 550, 1700, 550, 1700, 550, 1700, 550, 550, 600, 550, 550, 600, 550, 550, 550, 600, 550, 1700, 550, 1700, 550, 1650, 600, 550, 550, 600, 550, 550, 550, 600, 550, 550, 600, 550, 550, 1700, 550, 600, 550,550, 550, 600, 550, 550, 600, 550, 550, 550, 600, 1650, 600, 550, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1700, 550, 1650, 600};
unsigned int buttonRecord[68] = {4450, 4450, 600, 1650, 600, 1650, 600, 1650, 600, 550, 550, 550, 600,550, 550, 600, 550, 550, 600, 1650, 600, 1650, 550, 1700, 550, 600, 550, 550, 550, 600, 550, 550, 600, 550, 550, 1700, 550, 550, 600, 550, 550, 1700, 550, 550, 600, 550, 600, 1650, 550, 600, 550, 550, 600, 1650, 600,1650, 550, 600, 550, 1700, 550, 1650, 600, 550, 550, 1700, 550};
unsigned int buttonPlay[68] = {4500, 4450, 550, 1700, 550, 1700, 550, 1700, 550, 550, 600, 550, 550,550, 600, 550, 550, 600, 550, 1650, 600, 1650, 600, 1650, 600, 550, 550, 550, 600, 550, 600, 550, 550, 550, 600, 1650, 600, 1650, 600, 1650, 550,600, 550, 550, 600, 550, 550, 1700, 550, 550, 600, 550, 550, 550, 600,550, 600, 1650, 550, 1700, 550, 1700, 550, 550, 600, 1650, 600};
unsigned int buttonStop[68] = {4500, 4450, 550, 1650, 600, 1650, 600, 1650, 600, 550, 600, 500, 600, 550, 600, 550, 550, 550, 600, 1650, 600, 1650, 600, 1650, 600, 550, 550, 550, 600, 550, 550, 550, 600, 550, 550, 600, 550, 1700, 550, 1650, 600, 550, 600, 550, 550, 550, 600, 1650, 600, 550, 550, 1700, 550, 550, 600,550, 550, 1700, 550, 1700, 550, 1700, 550, 550, 600, 1650, 600};
// End of codes for buttons of Samsung BN5900706A
void setup()
{
Serial.begin(9600);
}
void loop() {
while(Serial.available()) {
character = Serial.read();
content.concat(character);
// content+=character;
}
if (content !=' ') {
if(content=='buttonPower') {delay(100);irsend.sendRaw(buttonPower,68,38);delay(100);Serial.println("buttonPower sent.");};
if(content=='buttonPlay') {delay(100);irsend.sendRaw(buttonProgramDown,68,38);delay(100);Serial.println("buttonPlaysent.");}
else {irsend.sendRaw(buttonRecord,68,38);};
Serial.println(content);
content=' ';
}
delay(1000);
}
答案 0 :(得分:0)
您可以将int
- 函数返回的Serial.read()
转换为byte
,如下所示:
character = byte(Serial.read());
编辑:此外,您似乎希望在变量content
中包含多个字符。 byte
只能包含一个ASCII字符。为了存储多个字符,我会使用String
- 类型:
String content = " ";
此外,您正尝试在以下比较中定义字节而不是字符串:
content !=' '
content=='buttonPower'
content=='buttonPlay'
他们应该改为:
content !=" "
content=="buttonPower"
content=="buttonPlay"