Let's Make Robots!

[FIXED] Serial write from command prompt and Gambas


I'm new to this forum and I'm also new to robotics in general, I do have some programming background which is very helpfull. I've got an Arduino Uno and I'm testing alot of it's features while I'm waiting for my robot-parts to arrive.

But now I'm stuck with this problem: I want to write a "message" via the Serial port using a GUI, so I found this open source program which is very similair to VisualBasic.NET (called Gambas), I made my simple GUI for testing purposes BUT it only works when the "Serial Monitor" of the standard Arduino IDE is opened. So I though "OK, it's maybe because there is a setting wrong in Gambas" but when I tried to sent a message via the serial port using the linux terminal (yes I'm a linux-user) with the following code: "echo 'test' > /dev/ttyACM0" I have the same problem.

This is the arduino code (but I don't think it has something to do with this problem):

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,10,5,4,3,2);
char tekst;

void setup(){

void loop(){
  if (Serial.available() > 0){
  tekst = Serial.read();

It's probably a stupid thing I didn't think of, I hope someone can help me with this :). Thanks in advance!

Regards Florian



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Thanks everyone for the help, but I've found the (stupid) problem.

I opened the port in the button_click()  sub and for some reason that doesn't work. When I open the port in the Form_Open() sub everything works :D

Regards from Belgium

The problem is that the arduino resets itself when you connect to it (the first time) and when you connect to it from the button click event you send data too early, before it has finished rebooting:

When the Uno is connected to either a computer running Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the following half-second or so, the bootloader is running on the Uno. While it is programmed to ignore malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of data sent to the board after a connection is opened. If a sketch running on the board receives one-time configuration or other data when it first starts, make sure that the software with which it communicates waits a second after opening the connection and before sending this data.

More info here, in the Automatic (Software) Reset section.

Thanks, interesting!

I did some searching. I will post the links here and let you see if they help you.

Actual search:
gambas serial connection linux - Google Search http://tinyurl.com/c2vdn7v

Links I followed:

Hopefully, something above will help.

Actually, having seen mention of ownership on two of those links, I bet your issue might be that you need to add yourself to the uucp group to have constant access to the COM port.

Here are a few things you might want to check:

Are you using the right serial port?  Are you sure ACM0 is the arduino?

Is the serial port configured properly with the right baud rate and other settings?

Did you completely exit the arduino IDE and terminal program or others that may be using the port?

What response or error messages are you getting from Gambas and at the command line? Just saying "it doesn't work" gives us nothing to go on.

Yes, it's the right serial port, it has to correct settings etc.

As I said, it "doesn't work" when I exit the arduino IDE, it only works with Gambas while the Serial monitor of the arduino IDE is opened. 

So I always have to open the Serial monitor and then I can run my Gambas program. When I do not open the Serial monitor and try to use the serial write of gambas I just got a blanck line (f.e. if I sent "test" with the arduino IDE serial monitor, and then close the serial monitor and try to sent it by only using Gambas there is not text at all, even "test" disappears...).

These are my settings in Gambas btw:

Have you considered Python and Tkinter? I have thrown a fairly basic GUI together with very little effort on my part.

I know it doesn't answer your original question, but, it offers an option to Gambas.

Thanks for the information but I'm not thinking of learning a total new language, I just need something simple (that's why I thought of Gambas).

I just installed a python IDE (The eric python ide), and it doesn't look that easy but maybe when I've got a lot of time it's worth learning :). It would be nice to fix the problem with gambas, just for short term then...