Send serial data (strings) from Arduino
So I have some spare time, so I looked at the Serial Communication using the Arduino device. I was able to successfully send messages from the Arduino board to the Arduino Serial Monitor on my laptop. I was able to send simple hard coded values as well as dynamically generated string messages.
#include <stdio.h> char serialstring[35]; void setup() { Serial.begin(9600); } void loop() { //print string directly Serial.println("This is a hardcoded string"); delay(1000); //setup string in a variable strcpy(serialstring,"This is a string inside a variable"); Serial.println(serialstring);//print string variable delay(1000); for(int j=0; j<3; j++) { //print the value of the variable J sprintf(serialstring,"Dynamic Message. Variable J = %d",j); Serial.println(serialstring); delay(500); } delay(10000); }
Once uploaded the results are as expected
And this concludes the Serial Communication Test for now. I think I will look at sending strings to the Arduino next time.
Categories: Arduino
Arduino, Arduino Uno, Serial Communication
Comments (0)
Trackbacks (0)
Leave a comment
Trackback