这是示例代码:
在此代码中,它检测美元符号,然后识别字符,1、2、3 等。如果输入,http://x.x.x.x/$1
- 意思是,它选择块条件 1。
等等。
我需要更改此代码,以便可以读取字符串并将其存储在变量中。
也许我可以拥有http://x.x.x.x/$25
或 45 美元或 100 美元等。
void connection()
{
EthernetClient client=server.available();
if (client)
{
boolean currentLineIsBlank=true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (incoming && c==' ')
{
incoming=0;
}
if (c=='$')
{
incoming=1;
}
//Checks for the URL string $1 or $2 and so on.
if (incoming==1)
{
if(c=='1')
{
//Insert something
}
if(c=='2')
{
}
if(c=='3')
{
redAll();
}
}
if(c=='\n')
{
currentLineIsBlank=true;
}
else if(c!='\r')
{
currentLineIsBlank=false;
}
}
}
delay(1);
client.stop();
}
}
我应该怎么办?让 Arduino 读取字符串。我应该用这段代码改变什么?