简体   繁体   中英

Displaying Unicode Characters with Arduino

I am currently using the Keyboard.h library on Arduino

I would like to display the following characters upon pressing a button on my breadboard: ♥ ♦ ♣ ♠

I don't know much about ASCII, Unicode and Hexadecimal so I'm having a hard time figuring this out

Does someone know how to do it?

Thanks.

Try Keyboard.print("\\uUNICODE_VALUE"); Unicode values can be found at: http://www.unicode.org/charts/

If that don't work on linux you can hit Ctrl + Shift + u , type the unicode value, and press enter like this:

void typeUnicode(int val, int time){
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press(KEY_LEFT_SHIFT);
    Keyboard.press('u');
    delay(time);
    Keyboard.releaseAll();
    delay(time);
    Keyboard.println(String(val, HEX));
    delay(time);
}

On Windows you havel "ALT codes", and i'm not sure how they work since i'm a unix geek.

See my answer at https://arduino.stackexchange.com/a/91365/70109 for how to convert from unicode to Octal for output

The GCC compiler used by Arduino also does not accept all unicode sequences such as Using octal avoids this problem. 在此处输入图像描述

Serial.print("\342\204\211");

will output ℉ provided the receiver has font for that unicode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM