### Project 2: The Globe

by huaishup @ 6:30 am 2 February 2011

1. Overall
When talking about data visualization, most of the people will think of computer graphic visualization. However, from my view, this is only one of the possible ways to do it. Why not trying visualizing data in physical ways? People can not only see the visualization result, but can also touch and manipulate the visualization device, which could be really interesting.

In this project, I explores the physical/tangible way of visualizing data. Using a paper globe as the data media, people can learn the language of a certain area by spinning the globe and adjusting the probe.

2. Material

Arduino x1

WaveShield with SD card x1

Button x1

Speaker x1

Variable resister x2

Paper

Wood

Wire

3. Process

a. Prepare the paper globe
Using google images to download one LANGE size global map. Download a Photoshop plugin called Flexify 2 to revise the map images. Here is the tutorial. Plot the revised image, cut and glue.

b. Fix the variable resistor
Laser cut 4 pieces of round woods to fix the shape of the paper globe. May use extra timber to do so. Install one of the variable resistor to the bottom of the globe. See below.

c. Install all the other parts
Install another variable resistor as the probe which points to the globe. Lazer cut a seat for the probe and the globe. Hook up two different Analog Input pins with the Arduino and resistors.

d. Calculate the position
Spin the globe and alter the probe. Different position has different resistor value, which can be mapped to the sound track. Calculate the position and map the sound track.

e. Prepare the sound
```#include #include #include #include "WaveUtil.h" #include "WaveHC.h"   char decision = 0; SdReader card; // This object holds the information for the card FatVolume vol; // This holds the information for the partition on the card FatReader root; // This holds the information for the filesystem on the card FatReader f; // This holds the information for the file we're play   WaveHC wave; // This is the only wave (audio) object, since we will only play one at a time   #define DEBOUNCE 100 // button debouncer   int mySwitch = 7;   // this handy function will return the number of bytes currently free in RAM, great for debugging! int freeRam(void) { extern int __bss_end; extern int *__brkval; int free_memory; if((int)__brkval == 0) { free_memory = ((int)&amp;free_memory) - ((int)&amp;__bss_end); } else { free_memory = ((int)&amp;free_memory) - ((int)__brkval); } return free_memory; }   void sdErrorCheck(void) { if (!card.errorCode()) return; putstring("\n\rSD I/O error: "); Serial.print(card.errorCode(), HEX); putstring(", "); Serial.println(card.errorData(), HEX); while(1); }   void setup() { // set up serial port Serial.begin(9600); putstring_nl("WaveHC with 6 buttons");   pinMode(mySwitch,INPUT);   putstring("Free RAM: "); // This can help with debugging, running out of RAM is bad Serial.println(freeRam()); // if this is under 150 bytes it may spell trouble!   // if (!card.init(true)) { //play with 4 MHz spi if 8MHz isn't working for you if (!card.init()) { //play with 8 MHz spi (default faster!) putstring_nl("Card init. failed!"); // Something went wrong, lets print out why sdErrorCheck(); while(1); // then 'halt' - do nothing! }   // enable optimize read - some cards may timeout. Disable if you're having problems card.partialBlockRead(true);   // Now we will look for a FAT partition! uint8_t part; for (part = 0; part &lt; 5; part++) { // we have up to 5 slots to look in if (vol.init(card, part)) break; // we found one, lets bail } if (part == 5) { // if we ended up not finding one :( putstring_nl("No valid FAT partition!"); sdErrorCheck(); // Something went wrong, lets print out why while(1); // then 'halt' - do nothing! }   // Lets tell the user about what we found putstring("Using partition "); Serial.print(part, DEC); putstring(", type is FAT"); Serial.println(vol.fatType(),DEC); // FAT16 or FAT32?   // Try to open the root directory if (!root.openRoot(vol)) { putstring_nl("Can't open root dir!"); // Something went wrong, while(1); // then 'halt' - do nothing! }   // Whew! We got past the tough parts. putstring_nl("Ready!"); }   void loop() { //putstring("."); // uncomment this to see if the loop isnt running if(digitalRead(mySwitch) == HIGH) { Serial.println("switch is ok"); int spin = analogRead(5); int probe = analogRead(2); Serial.println(spin); Serial.println(probe);   if(spin&gt;=0 &amp;&amp; spin&lt;=576 &amp;&amp; probe &gt;=179 &amp;&amp; probe &lt;=276) { playcomplete("r.wav"); } else if(spin&gt;=85 &amp;&amp; spin&lt;=313 &amp;&amp; probe &gt;=35 &amp;&amp; probe &lt;=160) { playcomplete("c.wav"); } else if(spin&gt;=580 &amp;&amp; spin&lt;=780&amp;&amp; probe &gt;=0 &amp;&amp; probe &lt;=142) { playcomplete("a.wav"); } else if(spin&gt;=980 &amp;&amp; spin&lt;=1023 &amp;&amp; probe &gt;=7 &amp;&amp; probe &lt;=22) { playcomplete("p.wav"); } else if(spin&gt;=980 &amp;&amp; spin&lt;=1023 &amp;&amp; probe &gt;=0 &amp;&amp; probe &lt;=7) { playcomplete("s.wav"); } else if(spin&gt;=1023 &amp;&amp; probe &gt;=47 &amp;&amp; probe &lt;=288) { playcomplete("e.wav"); } delay(1000); }   }   // Plays a full file from beginning to end with no pause. void playcomplete(char *name) { // call our helper to find and play this name playfile(name); while (wave.isplaying) { // do nothing while its playing } // now its done playing }   void playfile(char *name) { // see if the wave object is currently doing something if (wave.isplaying) {// already playing something, so stop it! wave.stop(); // stop it } // look in the root directory and open the file if (!f.open(root, name)) { putstring("Couldn't open file "); Serial.print(name); return; } // OK read the file and turn it into a wave object if (!wave.create(f)) { putstring_nl("Not a valid WAV"); return; }   // ok time to play! start playback wave.play(); }```