|
|
发表于 2016-6-14 18:59:19
|
显示全部楼层
王小鑫 发表于 2016-6-14 08:37 
是的,字符
int yanshi=0;
char val;
void setup() {
Serial.begin(115200);
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
if (Serial.available() > 0)
{
val = Serial.read();
if(val == 'A') yanshi=yanshi+10;
if(val == 'a') yanshi=yanshi-10;
if(val == 'B') yanshi=yanshi+100;
if(val == 'b') yanshi=yanshi-100;
if(val == 'C') yanshi=yanshi+1000;
if(val == 'c') yanshi=yanshi-1000;
}
if(yanshi<0)yanshi=0;
if(yanshi>1000)yanshi=1000;
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(yanshi); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(yanshi); // wait for a second
} |
|