我希望我的arduino告诉我什么时候运行它是例如 . “这是这个循环第22次运行 . ”我应该使用什么命令?我目前正在使用此代码:
Serial.print("This loop has run "); Serial.print(loopsRun); Serial.println(" times."); loopsRun++;
是的,我已经声明了所有变量,我只想知道是否有办法检查任何int的最后一位数 .
22%10 = 2你说22''1022%10 = 2你要说1022'nd'
27%10 = 7你说7''457%10 = 7你说457'th'
我的模式是否正确?如果是这样,那么您需要一个switch语句和一个%运算符
unsigned int remainder = loopsRun % 10; switch (remainder) { case 0: suffix = "th"; break; case 1: suffix = "st"; break; case 2: suffix = "nd"; break; <etc> }
1 回答
22%10 = 2你说22''1022%10 = 2你要说1022'nd'
27%10 = 7你说7''457%10 = 7你说457'th'
我的模式是否正确?如果是这样,那么您需要一个switch语句和一个%运算符