Go Down

Topic: IDE bug? (Arduino as keyboard) (Read 1 time) previous topic - next topic

mdrg

Nov 24, 2013, 07:59 pm Last Edit: Nov 24, 2013, 08:03 pm by mdrg Reason: 1
Hi,

Not sure this is a proper bug or this is the right place, but it's the only forum for bugs.

I was testing several of the examples provided along with the IDE, and then I reached to KeyboardMessage, which prints a message everytime you press a button. I tested on a text editor, it worked nice, but then I decided to print it on the IDE itself, just because. It turns out that the interface quickly starts to print gibberish everytime I press the button, every time printing text less and less similar to what it was supposed to be, until the point that even trying to quit it with the mouse no longer works, and I need to kill it through the OS or a command line.

The issue arises when I start to press the pushbutton more quickly. Maybe the interface can't handle the fast text input (however, even the sluggish Eclipse stays fine, despite the quite long freezes after some text, every couple clicks). May not be an "acceptable" bug, but still funny "breaking" the Arduino IDE with an Arduino :P

A screenshot is attached.

Environment:
Ubuntu 13.10 64 bits
Arduino IDE 1.0.5
Borderless Electronics Leonardo-compatible board (no quality issues whatsoever so far, dozens of examples tested - I tested pretty much everything from the basic examples up to "08.Strings" plus a few independent ones)
Text printing tested on gedit (simple text editor), LibreOffice Writer, Eclipse IDE, all of them work and no hangs.

PaulS

Quote
but then I decided to print it on the IDE itself

The Arduino can't communicate with the IDE. Did you mean the Serial Monitor? That is a separate application.

What code are you running?

mdrg

Hi PaulS,

I was not communicating with the IDE, just using it as a common text editor, as I did with gedit, LibreOffice Writer and Eclipse IDE.
Take a look at the screenshot, it will be clearer.

The code is this example:

Code: [Select]
const int buttonPin = 4;          // input pin for pushbutton
int previousButtonState = HIGH;   // for checking the state of a pushButton
int counter = 0;                  // button push counter

void setup() {
  // make the pushButton pin an input:
  pinMode(buttonPin, INPUT);
  // initialize control over the keyboard:
  Keyboard.begin();
}

void loop() {
  // read the pushbutton:
  int buttonState = digitalRead(buttonPin);
  // if the button state has changed,
  if ((buttonState != previousButtonState)
    // and it's currently pressed:
  && (buttonState == HIGH)) {
    // increment the button counter
    counter++;
    // type out a message
    Keyboard.print("You pressed the button ");
    Keyboard.print(counter);
    Keyboard.println(" times.");
  }
  // save the current button state for comparison next time:
  previousButtonState = buttonState;
}

Go Up