Hex to binary, LED blinking
You are almost there. Now you just have to read and parse the hex
numbers supplied by the user.

The simplest way to accept numeric user input is with
Serial.parseInt(). This is not always ideal since it involves blocking
the program until it either receives an invalid character or the reading
times out. It is also not applicable to your situation because it only
works with decimal numbers.

The better standard way to get the input is to put the incoming bytes
into a buffer until you catch a specific character designated as an end
of message marker. This is typically a CR ('\r' in C++) or an LF
('\n'). This technique is more involved than just calling parseInt()
but it is often preferred because it can be done in a non-blocking way.
See for example this simple command line interpreter.

In your case, however, you do not need to buffer the incoming bytes. You
can instead parse the hex number while you read it, like this:

void loop()
{
    if (Serial.available()) {
        static unsigned int val;
        int c = Serial.read();
        if (c &gt;= '0' &amp;&amp; c &lt;= '9') {
            val = 16 * val + (c - '0');
        } else if (c &gt;= 'a' &amp;&amp; c &lt;= 'f') {
            val = 16 * val + (c - 'a' + 10);
        } else if (c &gt;= 'A' &amp;&amp; c &lt;= 'F') {
            val = 16 * val + (c - 'A' + 10);
        } else {  // End of number.
            blink(countSetBits(val));
            val = 0;  // reset for next round
        }
    }
}