i want to hold "w" for forward motion. not "w enter, w enter, w enter"

Hello all,
So I have a two wheeled makings of a robot. I've got the basic "w enter" to go forward for a set amount of time (along with a,s,d), but i want to be able to hold "w" without the return key pressed every time to send the command thru the Console of the Yun. Once I get that down I will worry about the rest later. I would like the "w" to work first. Can this be accomplished with the yun console or is there some linux magic that must be done first. Here is one version of what I have:

#include <SoftwareSerial.h>
#include <Sabertooth.h>
#include <Console.h>

int inByte;

SoftwareSerial SWSerial(NOT_A_PIN, 11); // RX on no pin (unused), TX on pin 11 (to S1).
Sabertooth ST(128, SWSerial); // Wheels 128.
Sabertooth STT(129, SWSerial); //motor3. 

void setup()
{
  SWSerial.begin(9600);
  ST.autobaud();
  STT.autobaud();
  Serial.begin(9600);
   // initialize serial communication:
  Bridge.begin();
  Console.begin();

  while (!Console){
    ; // wait for Console port to connect.
  }
  Console.println("You're connected to the Console!!!!");
  // initialize the LED pin as an output:
}

void loop()
{
  if (Console.available() > 0) {
    int inByte = Console.read();
    Console.println(inByte);
    Console.println(char(inByte));

    switch (inByte) {
    case 'w':    
      ST.motor(1, 30); // forward
      ST.motor(2, 30); // forward
      break;
    case 's':    
      ST.motor(1, -30); // Reverse 
      ST.motor(2, -30); // Reverse
      break;
    case 'a':    
      ST.motor(1, -10); // turn L
      ST.motor(2,  10); // turn L
      delay(500);
      ST.motor(1, 0); // stop
      ST.motor(2, 0); // stop
      break;
    case 'd':    
      ST.motor(1,  10); // turn R
      ST.motor(2, -10); // turn R
      delay(500);
      ST.motor(1, 0); // stop
      ST.motor(2, 0); // stop
      break;
    case '2':    
      ST.motor(1, 127); // forward  fast
      ST.motor(2, 127); // forward  fast
      delay(500);
      ST.motor(1, 0); // stop
      ST.motor(2, 0); // stop
      break;
    case 'x':    
      ST.motor(1, 127); // reverse  fast
      ST.motor(2, 127); // reverse  fast
      delay(500);
      ST.motor(1, 0); // stop
      ST.motor(2, 0); // stop
      break;
    case 'b':    
      STT.motor(1, 127); // motor 3
      delay(2000);
      
    default:
      ST.motor(1, 0); // off
      ST.motor(2, 0); // off
      STT.motor(1, 0); // blade off
    }
  }
}

Hopefully answered a bit of my own question from the end of this How do I parse Arrow Keys from Telnet Client - Networking, Protocols, and Devices - Arduino Forum.
The putty "local line editing" off sounds like it should work but it hasn't for me yet. I think I need to modify my code. Or its not working for me because I ssh to the Yun and then I telnet to localhost from there. I can send one "w" and it works but holding "w" doesn't make a continuous forward. I'll look harder through my code tomorrow to try to get it to act like "newb91"'s. Any thoughts or suggestions?

You need to have autorepeat enabled for your keyboard, for that to work.

Is autorepeat a putty option? Or is it a system setting for the keyboard? If i open a program a hold down a key it does repeat. But my problem is that I want the behavior to also stream to the arduino. It would have to look like "w Enter w Enter w Enter" in putty. Not "wwwww Enter".

I suspect you will need to write your own PC program to get the behaviour you are describing.

...R

Robin2:
I suspect you will need to write your own PC program to get the behaviour you are describing.

...R

If I did write my own program to send the repeat characters, where exactly would it sent it to? Would it work to send them to the port 6571 because is how it currently works. Or would that not work because it involves ssh to arduino and THEN telnet? It would be great if i could make arduino just listen on a port and forward all character to the sketch.!

I can't answer your question about where it would send it to.

I presume it would be possible to write a program that would appear to the Arduino just as the Serial Monitor does - except that it would know how to send lots of Ws without you having to press enter.

...R

I actually have a cobbled together program that can pretty much work on the linux side but if I go the programming route I guess the main thing in my way is getting the arduino to receive the sent characters. Thank you for your input though.

I had the impression from your first post that the Arduino has no problem receiving the data when you do W enter W enter. So why should it have any difficulty if your program sends W W W. In any case your program could easily be made to send lots of "W enter"s.

Perhaps you should explain exactly what you are doing. I assumed you are pressing keys on a PC keyboard to send data from the Arduino Serial Monitor to a Yun. But maybe I have it all wrong.

...R

nofed:
Is autorepeat a putty option? Or is it a system setting for the keyboard?

In Windows, it's a keyboard setting. You haven't said what platform you're using.

Robin2:
I had the impression from your first post that the Arduino has no problem receiving the data when you do W enter W enter.

I am using Windows sometimes and Linux at other times for my main OS. If I use the Console for the YUN to send the char "w" and then hit enter, the motors work to go forward for only a split milisecond. If I type wwwwwwwwwwww and enter, then the moter goes forward for a little bit longer. But I have to hit enter in the console. And the console sends all the w's at the same time. I want to not have to hit enter to get the characters to the arduino side. I want to stream W's A's S's and D's to control a robot.

The other senario I've been trying is to modify existing linux programs to capture keystrokes and pipe the data to other places. The problem with this senario is I don't know where to pipe the data to. To access my YUN I usually ssh into it. The only command line way that works for my to get streaming data to the arduino side from the linux side is to telnet from ssh "telnet localhost 6571" and then send one char at a time thru ssh thru the telnet connection. But then I'm back to the problem of sending one char and then having to hit enter. I have not found any streaming ability thru this way of connectting. But my telnet knowledge is limited.

PeterH:

nofed:
Is autorepeat a putty option? Or is it a system setting for the keyboard?

In Windows, it's a keyboard setting. You haven't said what platform you're using.

Thanks. I'm not currently at my windows computer, but I'm almost positive its got the repeat on. But I will check this later.

The Arduino IDE serial monitor buffers your keyboard input and only sends the buffered text when you hit 'enter'. It does not have any mode which sends characters immediately they are typed. Give up any idea of getting this working using the serial monitor.

I don't know what's happening when you SSH into the YUN. Presumably somewhere along the way you're ending up with autorepeat disabled.

I suggest you look for a Windows based solution using something like Realterm which lets you send characters as they are typed i.e. without buffering them.