Keyboard.print("/check"); but output is: -check

Hi everybody,

I try to send a slash
I tried / ----> Displays a minus sign
I tried ASCII: Keyboard.write(0x2f); ----> Displays also minus sign
I tried Keyboard.write(//check); display two minus

I am getting mad!

Could pls anybody help?

Regards
Mario

What is the output device?

Hi J,

ich checked it on apple and on windows. The same output: a minus sign

Regards
Mario

I tried Keyboard.write(//check); display two minus

This doesn't make sense. "//" starts a comment.

Please post your code, not snippets.

How to use this forum

http://snippets-r-us.com/

mariomueller:
I am getting mad!

I’m starting to get mad too! You are cross-posting.

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

You are not reading the forum posting guidelines.

Please use code tags.

Read this before posting a programming question

This reply (which you did not mention here, which is why we don't like cross-posting) may well be the correct one:

HI nick,

sorry. But did you think why i did cross-posting?

a) first post was a german forum
b) I did not receive an answer there

What is false there . If you want arduino to become popular, you shouldn't give answers like yours. This is not good for the acceptance of arduino.

Hi nick,

the answer on the german forum did not work.

Regards Mario

Please post your whole sketch.

When you say you checked it on Windows and Mac, do you mean you just ran a standard serial communications program, displaying characters received on the serial port?

I suspect the systems you are using are expecting a German keyboard. The Arduino library uses the US English key codes. When you say '/' it used the US English keycode 0x38 (?/). On that key the German keyboard has (_-). On a German keyboard you would use Shift-7 to get a slash. On the US English keyboard that would get you a '&'. Just put an '&' where you want to send '/'.

Or you could edit the hardware/arduino/avr/cores/arduino/HID.cpp file to change the ASCII->keycode mapping for a German keyboard.

mariomueller:
sorry. But did you think why i did cross-posting?

a) first post was a german forum
b) I did not receive an answer there

Sorry, but you are lying.
Not very nice of you.

You received the top answer with reply #1:

And that's totally right what user 'combie' wrote.

You are sending keyboard scancodes for the US layout of the keyboard, and you don't have something like a "German keyboard driver loaded" in your Arduino sketch.

What you are trying to do is using the US keyboard layout:

And now have a look where the slash is in the US keyboard layout and what character is in the same position on your German keyboard!

If you don't understand answers in the German forum, you are allowed to request further expanations.

Instead: You replied nothing to any answer you got in the German forum. Not a "thank you" and not "I don't understand". Nothing! You created a new thread in the German forum. You got a correct answer. And you were never seen again in that thread of the German forum.

ho jurs,

sorry.
Yes it is true. There was an answer in the german forum; but this did not work. So i had better written; there was no sattisfiing answer. At least it is the same
I also tried ascii; which also didn't work.

And I wonder what people are here in the forum?

  • one is getting mad, because I was cross posting; oh, what a tragedy. The world is going under
  • the other calls me a liar

BTW: I am german :grin:

Regards Mario

Here is the sketch (from Ohmmeter)
I just wanted to redirect serial output to keyboard.

// Widerstände messen

//              _____
//            -|_R1__|- VCC
//AnalogPin  -' _____
//           '-|_R2__|- GND

// R2 = zu messender Widerstand

float Quellspannung=5.0;
int AnalogPin=5;
int R1=1500.0; //Wert des bekannten Widerstands (der mitgelieferte 1,5k-Widerstand)
long Messwert;
float SpannungR2; //Spannung über dem zu messenden Widerstand
float Widerstand;

void setup()
{
  Serial.begin(9600);
  Serial.println("Widerstand ausmessen");
  Serial.println();
}

void loop()
{
  //5 Messungen machen und Mittelwert bilden
  Messwert=0;
  for(int i=0;i<5;i++){
    Messwert+=analogRead(AnalogPin);
  }
  Messwert=trunc(Messwert/5);
  
  //Spannung berechnen
  SpannungR2=(Quellspannung/1023.0)*Messwert;
  Serial.print("Spannung ueber R2 betraegt ");
  Serial.print(SpannungR2,2);
  Serial.println(" Volt!");
//########
Keyboard.write("/check"); 
//########
  //Berechnung: (R2 = R1 * (U2/U1))
  Widerstand=R1*(SpannungR2/(Quellspannung-SpannungR2));
  Serial.print("Der Widerstand hat ");
  Serial.print(Widerstand,2);
  Serial.println(" Ohm.");
  Serial.println();
  delay(1000);
}

mariomueller:
I also tried ascii; which also didn't work.

By "tried ascii" do you mean you use the '&' character in place of your '/' and still got a '-'? I was sure that would work.

mariomueller:
HI nick,

sorry. But did you think why i did cross-posting?

a) first post was a german forum
b) I did not receive an answer there

What is false there . If you want arduino to become popular, you shouldn't give answers like yours. This is not good for the acceptance of arduino.

Cross-posting is cross-posting. Doing it in different languages does not change that. If you post in German, Spanish, English, French and Swahili that is cross-posting. You are trying to increase the chance of a reply.

It is like people cross-posting in Programming, Electronics, Sensors, and Problem Solving. Same thing.

If you want arduino to become popular, you shouldn't give answers like yours.

I don't want people who work hard answering questions to have to answer them twice because of cross-posters. Like it leave it.

b) I did not receive an answer there

You did get an answer, which I referred to above. The question was, why are you getting strange characters when you use the keyboard class. The suggested answer was different keyboard layouts, which I thought could be correct.

mariomueller:
Here is the sketch (from Ohmmeter)

Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” button above the posting area (It looks like a scroll with < > inside it).

Clearly you haven’t read the forum rules. I suggest you read them now.

How to use this forum

Hi johnwasser,

yes, I tried ASCII: Keyboard.write(0x2f);

Shows: ---

Regards Mario

mariomueller:
Hi johnwasser,

yes, I tried ASCII: Keyboard.write(0x2f);

Shows: ---

Regards Mario

Hi Mario,

I have never tried using the Keyboard class, but you don't seem to ever call Keyboard.begin() in your setup. Here's some sample code from the class description.

void setup() {
  // make pin 2 an input and turn on the
  // pullup resistor so it goes high unless
  // connected to ground:
  pinMode(2, INPUT_PULLUP);
  Keyboard.begin();
}

void loop() {
  //if the button is pressed
  if(digitalRead(2)==LOW){
    //Send the message
    Keyboard.print("Hello!");
  }
}
[code]

ps: This is why it is important to always post the entire sketch.

mariomueller:
Hi johnwasser,
yes, I tried ASCII: Keyboard.write(0x2f);

That is equivalent to saying Keyboard.write('/'); which we know doesn't work because the US English keycode for '/' is the German keycode for '-'. Try Keyboard.write(0x26); or Keyboard.write('&');. That should get you the German keycode for '/'.

PROBLEM SOLVED

@John: you are my hero of the day.
0x26 works fine

I thought ASCII is ASCII regardless which keyboard is used.

Slowly but surely.

Many many thanks to all.
Sorry for the inconveniences concerning the cross posting.
I promise to be not confusing the next time!

Regards

Mario