Color Compass

Views: 10985 Difficulty: 4 Status: Complete

Coupling the HMC5883L Compass with our color library turns the Wearable Wayfinder into a handy navigation device.

Turn the Wearable Wayfinder into a a compass! Compasses help us orient ourselves in the world. The HMC 5883L is an affordable 3-axis compass. If you want to learn more about the HMC5883 Bildr has a great tutorial and library to get you started. You can get the compass from sparkfun or digikey. We connect the compass to a SMD package arduino hooked up to a TFT LCD Screen. We use our arduino color library to color the compass hand rainbow colors depending on where it is facing.

Compasses Perpendicular

Orthogonally arranged compasses showing 3 of 4 of the cardinal directions!

Wearable Wayfinder Color Compass Video

Check those directions!

Compass Video

Color compass accelerated. Strong magnets will confuse it.

Arduino Code

First, make sure you have the Wearable Wayfinder libraries installed. Okay now that we got the dependencies down, we've got some functions to talk about:
int get_color_from_angle(int angle){
  Color cur_color=Color(0,0,0);
  return cur_color.get_color_16bit(); 
This function translates from a degree ((0-360) that we got from the compass which represents our heading) and a color. Using the HSB color mode the above code maps each heading to a different hue. Then once we have read the heading from the compass (it is given in radians) we draw a ray and two orbiting circles rotated by the heading:
float headingDegrees = heading * 180/M_PI; 
  draw_ray(64,80, headingDegrees, 40);
  draw_orbiter(64,80, headingDegrees, 22,6);
  draw_orbiter(64,80, headingDegrees, 32,3);
/* LucidTronix Wearable Wayfinder color compass 
 * Rainbow colored wearable navigator 
 * For instructions, details and schematic, See:

#include <WearableWayfinder.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <Wire.h>
#include <SPI.h>
#include <Color.h>
#include <HMC5883L.h>
#include <MCP79410.h>
#include <I2C.h>
#include <MMA8453Q.h>

// for leo:
Adafruit_ST7735  tft = Adafruit_ST7735(SS, 9, 8);
WearableWayfinder ww = WearableWayfinder(&tft);

String directions[] = {"North", "North-west", "West", "South-west", "South", "South-east", "East", "North-east"};
const int num_directions = 8;
int old_direction_index = 0;
float old_heading = 0;

void setup(){
  Wire.begin(); // Start the I2C interface.

void loop(){
  ww.draw_string(5, 3, "Compass", ww.stroke.color_16(), 2);
  float heading_degrees = ww.get_heading();
  if(abs(heading_degrees - old_heading) > 3 ){
     tft.fillRect(22, 38, 82, 82, ww.background.color_16()); 
  old_heading = heading_degrees;
  ww.draw_ray(64,80, heading_degrees, 40);
  ww.draw_orbiter(64,80, heading_degrees, 22,6);
  ww.draw_orbiter(64,80, heading_degrees, 32,3);
  int direction_index = map(heading_degrees, 0, 359, 0, num_directions);
  if(old_direction_index != direction_index){
    tft.fillRect(2, 128, 108, 12, ww.background.color_16()); 
    ww.draw_string(5, 128, directions[direction_index], ww.stroke.color_16(), 1);
  old_direction_index = direction_index; 
  ww.show_heading(10, 145);
  if ( digitalRead(ww.btn1_pin) == HIGH){


Title Description # Cost Link Picture
Wearable Wayfinder An Arduino on steroids! Full color LCD screen, accelerometer, compass, and real time clock loaded onto a wearable gadget! 1 $69.95 Link 3screens2
The Wearable Wayfinder is a totally programmable, beautiful little computer for your wrist packed wit...
Wearable digital compass displays the direction in green LEDs....
A wearable real-time clock with vibrant color display....
Play pong on a little LCD screen with two big joysticks....
Standalone programmable Heart-Shaped LED display....
Handheld gaming machine, based on the Arduino Leonardo, equipped with joystick, SD card and more....
Control the hue, value and saturation on this pocket-sized joystick drawing machine....
Mixing pixels from two face images together....