最佳答案
如何将 int (n
)转换为字符串,以便当我通过序列发送它时,它被作为字符串发送?
This is what I have so far:
int ledPin=13;
int testerPin=8;
int n=1;
char buf[10];
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(testerPin, OUTPUT);
Serial.begin(115200);
}
void loop()
{
digitalWrite(ledPin, HIGH);
sprintf(buf, "Hello!%d", n);
Serial.println(buf);
delay(500);
digitalWrite(ledPin, LOW);
delay(500);
n++;
}