println("\n\nchanging the Strings' values"); stringOne = "A long integer: "; stringTwo = "The millis(): "; // 使用 concat() 来为子妇产添加一个长变量 stringTwo.concat(millis()); Serial.println(stringTwo); while(true); } 输出结果: 改变字符串的大小写 可以使用 toUpperCase 和toLower...
Serial.print(data) 从串行端口输出数据。Serial.print(数据)默认为十进制等于Serial.print(数据,DEC)。 Serial.print(data, encoding) 经序列埠传送资料,提供编码方式的选项。Serial.print(数据,数据的进制)如果没有指定,预设以一般文字传送。 范例: Serial.print(75); // 列印出 "75" Serial.print(75, DEC)...
pinMode(buttonPin, INPUT); } // loop 中每次都检查按钮,如果按钮被按下,就发送信息到串口 void loop() { if (digitalRead(buttonPin) == HIGH)//通过eigitalRead读取到针脚3的电平值是否为高 serialWrite('H');//是高就通过串口写出H else serialWrite('L');//如果不是就通过串口写出L delay(1000)...
25.1.1 if(Serial) 25.1.2 Serial.available() 25.1.3 Serial.begin() 25.1.4 Serial.end() 25.1.5 Serial.find() 25.1.6 Serial.findUntil() 25.1.7 Serial.flush() 25.1.8 Serial.parseFloat() 25.1.9 Serial.parseInt() 25.1.10 Serial.peek() 25.1.11 Serial.print() 25.1.12 Serial.println() ...
Serial.print(“ciao”); } switch case if叙述是程序里的分叉路口,switch case 是更多选项的路口。Swith case 根据变量值让程序有更多的选择,比起一串冗长的if叙述,使用swith case可使程序代码看起来比较简洁。 范例: switch (sensorValue) { case 23: ...
// resulting substrings into an integer array: float[] colors = float(split(inString, ",")); // if the array has at least three elements, you know // you got the whole thing. Put the numbers in the // color variables: if (colors.length >=3) { ...
4.2 SimpleIntegerList——简单int类型集合 实例源码: // int为类型的list集合 #include <LinkedList.h> LinkedList<int> myList = LinkedList<int>(); void setup() { Serial.begin(9600); Serial.println("Hello!"); // Add some stuff to the list ...
Len_Integer = Len_mm_X100/100; Len_Fraction = Len_mm_X100%100; Serial.print("Present Length is: "); Serial.print(Len_Integer, DEC); Serial.print("."); if(Len_Fraction < 10) Serial.print("0"); Serial.print(Len_Fraction, DEC); ...
Serial.begin(9600); }voidloop(){ Serial.print('H');//send a header characterintValue = random(591);//generate a random number between 0 and 590Serial.write(lowByte(intValue));//send the low byteSerial.write(highByte(intValue));//send the high byte//send another random integerintValu...
volatile int pulsecount; //Volatile integer to store pulse count in void setup() { Serial.begin(9600); rtc.begin(); //start rtc pinMode(Pulses, INPUT); //Make Pin2 Input attachInterrupt(digitalPinToInterrupt(Pulses), CountPulses ,FALLING); //Use interrupt on "Pulses" Pin, count on the...