Buy the components
string-functions.ino
String sample; String animal = "lion"; void setup() { Serial.begin(9600); Serial.println("String functions..."); Serial.print("string.length(): "); Serial.println(animal.length()); } void loop() { temperature(sample); Serial.print("Temperature returned: "); Serial.println(sample); delay(1000); } void temperature(String &value) { value = String(random(0, 30)); }
BOARD?=arduino:avr:uno PORT?=/dev/cu.usbmodem14* BUILD=build .PHONY: default lint all flash clean default: lint all flash clean lint: cpplint --extensions=ino --filter=-legal/copyright,-runtime/references *.ino all: arduino-cli compile --fqbn $(BOARD) --output-dir $(BUILD) ./ flash: arduino-cli upload --fqbn $(BOARD) --port $(PORT) --input-dir $(BUILD) clean: rm -r build
A photo of the actual setup.
Serial output from the firmware.
Examples of various String functions and how to pass the function a reference to a String object that you want to write to.