Skip to main content
added 2 characters in body
Source Link

I have the following code:

#include <SoftwareSerial.h>
#include <Keyboard.h>

SoftwareSerial ttySerial(10, 11); // RX, TX
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Native USB only
  }

  Serial.println("Serial Initialized");

  //Set the data rate for the SoftwareSerial port
  ttySerial.begin(115200);
  ttySerial.println("tty Initialized");

  Keyboard.begin();
}

void loop() 
{
  while (ttySerial.available())
    //Serial.write();
    Keyboard.write(ttySerial.read());
    
//    if (Serial.available())
//      ttySerial.write(Serial.read());
}

my problem is that ttySerial.read() is an int and I thought that the Keyboard.write method could hand integer arguments: Keyboard.write(32) should write """< space >" not "32".

Any ideas what is going on?

I have the following code:

#include <SoftwareSerial.h>
#include <Keyboard.h>

SoftwareSerial ttySerial(10, 11); // RX, TX
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Native USB only
  }

  Serial.println("Serial Initialized");

  //Set the data rate for the SoftwareSerial port
  ttySerial.begin(115200);
  ttySerial.println("tty Initialized");

  Keyboard.begin();
}

void loop() 
{
  while (ttySerial.available())
    //Serial.write();
    Keyboard.write(ttySerial.read());
    
//    if (Serial.available())
//      ttySerial.write(Serial.read());
}

my problem is that ttySerial.read() is an int and I thought that the Keyboard.write method could hand integer arguments: Keyboard.write(32) should write "" not "32".

Any ideas what is going on?

I have the following code:

#include <SoftwareSerial.h>
#include <Keyboard.h>

SoftwareSerial ttySerial(10, 11); // RX, TX
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Native USB only
  }

  Serial.println("Serial Initialized");

  //Set the data rate for the SoftwareSerial port
  ttySerial.begin(115200);
  ttySerial.println("tty Initialized");

  Keyboard.begin();
}

void loop() 
{
  while (ttySerial.available())
    //Serial.write();
    Keyboard.write(ttySerial.read());
    
//    if (Serial.available())
//      ttySerial.write(Serial.read());
}

my problem is that ttySerial.read() is an int and I thought that the Keyboard.write method could hand integer arguments: Keyboard.write(32) should write "< space >" not "32".

Any ideas what is going on?

Source Link

Keyboard.write writing ASCII integer value as a String

I have the following code:

#include <SoftwareSerial.h>
#include <Keyboard.h>

SoftwareSerial ttySerial(10, 11); // RX, TX
void setup()
{
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Native USB only
  }

  Serial.println("Serial Initialized");

  //Set the data rate for the SoftwareSerial port
  ttySerial.begin(115200);
  ttySerial.println("tty Initialized");

  Keyboard.begin();
}

void loop() 
{
  while (ttySerial.available())
    //Serial.write();
    Keyboard.write(ttySerial.read());
    
//    if (Serial.available())
//      ttySerial.write(Serial.read());
}

my problem is that ttySerial.read() is an int and I thought that the Keyboard.write method could hand integer arguments: Keyboard.write(32) should write "" not "32".

Any ideas what is going on?