// LAB 10 · INTERACTIVE
Binary and hex converter: flip 8 bits
Flip 8 bits and see the number in decimal, hex and binary — plus the PORTB line to write it.
⚡ POWERING UP THE LAB…
// HOW IT WORKS
The idea in 30 seconds
- Each bit is worth double the one on its right: 1, 2, 4, 8, 16, 32, 64, 128.
- Add the ON bits to get the decimal number. 8 bits go from 0 to 255.
- Hex groups 4 bits (a nibble) into one digit 0–9, A–F: 0b0010 0000 = 0x20 = 32.
- Shift left (<<) doubles the number; shift right (>>) halves it.
Watch the lessons
More labs
All labs →LAB · INTERACTIVE · NEWLogic gatesFlip two switches and watch AND, OR, NOT, XOR and friends decide if the lamp lights.LAB · INTERACTIVE · NEWPWM dimmerChange the duty cycle and the speed: see the square wave, the average voltage and the LED dim.LAB · INTERACTIVEResistor colour codeTap the bands, read the value — then beat the decode challenge.

