Wednesday, June 24, 2015

Morse code over laser light with an Arduino

19. After another of my famously lavish parties, I sometimes walk alone out to Promontory Point at exactly 10:00 p.m. Thursday and glance lakeward, out at a blinking light on some distant shore, and think of Daisy Buchanan. That light winks on and off, unattainable, a powerful metaphor for|wait, is that Morse code? [5 points for lights over a mile away; 15 points for lights over 5 miles away; 0 points for lights that are only metaphors] For this Scav Hunt item I used an Arduino to turn a laser pointer on and off in morse code:
#define pulseHigh(pin) {digitalWrite(pin, HIGH); digitalWrite(pin, LOW); }
#define RESET 13  // Pin 13 

void setup() {
pinMode(13, OUTPUT);
}

void loop() {
      
      digitalWrite(13,HIGH);
      delay (3000); 
      digitalWrite(13,LOW);
      delay (1500);
      dash();dash();dot();space();
      dot();dash();space();
      dot();dot();dot();space();
      dot();dot();dot();dot();space();
      delay(2000);
      
      
      pulseHigh(RESET); // off
};


void dot()
{
  digitalWrite(13,HIGH);
  delay(100);
  digitalWrite(13,LOW);
  delay(100);
  
}

void dash()
{
  digitalWrite(13,HIGH);
  delay(300);
  digitalWrite(13,LOW);
  delay(100);
  
}

void space()
{
  digitalWrite(13,LOW);
  delay(300);
}


I checked and saw at http://www.heywhatsthat.com/?view=PKDC86DD that the path from Adler Planetarium to the Point was just a touch over five miles and free. I could identify the Point fairly well in binoculars; I aimed the laser pointer by fixing to a tripod, testing the aiming by hitting nearer objects (a beach buoy nearby happened to be retroreflective which helped quite a bit) and then carefully moving the system towards the Point. I turned it off whenever boats went near the beam. To prove it was me, the judge requested I manually hit the key a few times--since I had only a programmed 'SCAV' (yes, it says GASH above), I manually connected the pointer to 5V & ground on the Arduino. It was powered via a 12V battery and a cigarette lighter USB charger to provide 5.1V.