Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:46:45+00:00 2026-05-27T06:46:45+00:00

I have a function that takes 24 bit to 12 bit hex and prints

  • 0

I have a function that takes 24 bit to 12 bit hex and prints the colour value on an LCD.

If a user inputs the RGB values, how can I convert the RGB to a single 24-bit hex string?

I found many Java and C++ algorithms online, but I can’t seem to make them compatible with the Arduino.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:46:46+00:00Added an answer on May 27, 2026 at 6:46 am

    Last I looked, Arduino doesn’t have a nice way to print other formats, like with printf(). So you’ll have to convert to hex yourself or find an existing function that does it by turning real ints to hex character representations. Here’s one way:

    I assume that “24 bit” is the RGB values and that’s 3 8 bit numbers of 0-255, as per usual. In that case, you’ll have two digits of hex for each decimal number. Let’s illustrate with R = 243.

    The first hex “digit” will be h1 = int(R/16) which is 15.
    The other will be h2 = R - h1*16 which is 3.

    But those “digits” are still decimal numbers. So have a lookup table in an array, for instance, where the index of the array is the decimal number and the value is the hex character.

    So for instance you’ll have lookup[15] = 'F' and lookup[3] = '3'.

    Just print out all these digits with no whitespace and you are done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C function that takes as paramenter an 8 bit integer int8_t
I have a function that takes a parameter(key) to retrieve it's value from a
I'm a bit confused: I have a function, that takes an Object as argument.
I have a function that takes, amongst others, a parameter declared as int privateCount
I have a function that takes a struct, and I'm trying to store its
I have a function that takes pointer to pointer to struct. struct ABC; void
I have a function that takes a string-like argument. I want to decide if
I have a function that takes a const D3DVECTOR3 *pos , but I have
I have a function that takes 2 parameters : 1 = XML file, 2
I have a function that takes variadic arguments, that I obtain from func_get_args() .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.