java:
kotlin:
python:
swift:
Arduino C++
read serial from PC on Arduino
[/code]
Code:
Scanner scanner = new Scanner(System.in);
System.out.println("enter input");
String str1 = scanner.nextLine();
System.out.println("input was: " + str1);
kotlin:
Code:
Scanner scanner_variable = Scanner(System.`in`)
println("enter input")
var s1:String = scanner_variable.nextLine()
println(s1)
python:
Code:
word = input("enter word\n")
print(word)
swift:
Code:
print("Enter your favorite programming language:")
var name = readLine()
print("Your favorite programming language is \(name!).")
Arduino C++
read serial from PC on Arduino
Code:
(input on serial monitor window on PC)
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
int msg = Serial.parseInt();
Serial.println(msg);
}
}