Communicating via Arduino Serial Monitor


#1

Hey everyone,

how can i communicate with the robot by using the Arduino Serialmonitor? What are the commands to control the robot?


#2

http://wiki.makeblock.cc/library/docs/class_me_serial.html

The command functions are supported for creation in mBlock with the communication extensions enabled, but the Arduino monitor works better IMO. Once built I move to edit with Arduino IDE and use the serial monitor there.

Here is a snippet:

If you wish to send data to the serial monitor, use the Serial.print or Serial.println (includes line return).

The Serial.read command will read, but sending data to the com port from PC would require a terminal emulation program I imagine.

One to try…I’ll put that on the list.


#3

Thank you for your reply,

i want to write my own program in c# to control the robot. If i write my own Arduino code i am able to get the data from the robot, but with the standart Arduino code delivered with the robot it wont work, So my question is what do i need to send to the robot in order to get the sensor data etc. in return?


#4

As @Gort mentioned, you can use Serial.print or Serial.println(sensor data) to see the sensor data. Here is an example with Arduino IDE:


#5

Writing my own Code like this works fine, but isn’t there a way to get the data from the robot with the original firmware?


#6

Well, that depends on what the firmware program was written to do. The ‘default’ program may be sending data to the serial monitor, but what data?

You need to start with, “What data do I want and why?”

In the example, we send out Ultrasonic data so we can observe what the ultrasonic is reading.

It is doubtful the original firmware does exactly what you want, so you will be writing your own code. Using the mBlock helps show the correct syntax (spelling, punctuation and format), and you can build from there.

As for sending data to the robot, I had forgotten there is a send data window at the top of the serial monitor. The serial.print is easy, but the read is a but more tricky, and again, the mBlock ‘drag and drop’ code can be easier to get working, the c++ code is displayed when you choose ‘Arduino mode’ from the edit menu.

But again, what data are we SENDING, and what does robot do with it? We can send commands or data, but it has to be written to a variable and used in some way or there really is no reason.

So I would start with the flowchart of what you would like to do, and build your program from there.


#7