Merry Christmas From HogwartsTech

Posted on Tue 25 December 2018 in misc

The clock was about to strike 12 and I found myself pondering over this question on the christmas eve -

what is the geekiest way I could wish christmas, right now? 

Well, I was too lazy to get up and walk around in this freezing cold (even if I had to get anything). So it has to be here, sitting on my chair.

Hmm...let's see what I have around here within my reach - a book, few notebooks, HP Probook 4540s laptop, LG 22MP68VQ IPS display monitor, a JBL Go Speaker, Redmi Note 5 smartphone, pencils, pen, an eraser, extension chord, stationary holder, a cello-tape dispenser, stapler, poster colors, earphone, glue, paperweight, dismantled washing-machine timer, table drawer filled with spare parts, calculator, 1TB Seagate external hard drive, few blank papers, bread board and Arduino Mega 2560 board.

See if you can churn out a different way to wish using these combination before me. 

For me, the easiest thing was to do something with my Arduino board. But what? I don't have any sensor, actuator or end effector. All I have is the default LED ligth on the board at PIN 13. It has to be light.

How do I convert my text into light? Morse code was the first thing that came in my mind. I searched for the Arduino library that converts text into Morse code and there I found this arduinomorse repository by Mark Fickett. It consisted of a header file and one cpp file along with read instructions. There was a little example mentioned at the bottom which was just perfect for my job. All I had to do was to replace the text.

#define PIN_STATUS  13
#include "morse.h"

LEDMorseSender sender(PIN_STATUS);

void setup()
{
  sender.setup();
  sender.setMessage(String("merry christmas!"));
  pinMode(PIN_SENSOR, INPUT);
}

void loop()
{
  if (!sender.continueSending())
  {
    delay(5000);
    sender.startSending(); 
  }
}

I had converted my text to all lowercase as it was instructed. But, as it goes with programming (especially when you are in hurry), I encountered a compilation error. I checked the code. - All files placed properly - checked - Header file angular brackets changed to double inverted comma (to refer to internal file) - checked - Code - checked. No undeclared variable error

I skimmed through the console again and again. Everytime, I just saw that there was referencing error for the header file. I checked it. Modified. Checked again. Searched for the problem, landed at Stackoverflow but to no avail.

It's so damn simple! where am I going wrong? - I thought to myself.

I was getting restless (remember how it had to be a quick spinoff out of laziness?). Then suddenly, I glanced over the console once again and read the entire error. Problem in .cpp file. Morse.hnot found. So, I checked the cpp file and there it was - angular bracket for the internal header file. I changed it to double inverted comma and voila! It compiled. I think the author should have put this into instructions or not use angular brackets. It isn't the default library after all. Anyway, this made it a bit more interesting.

Later, when I was making its video, I realized, it was blinking way too fast for me to decode. Also, there wasn't any delay for the start of the next sequence to indicate that the entire text has been relayed. Since loop has been programmed to run infinitely, it's almost impossible to spot the beginning of next turn through naked eye. So I added a 5 second delay and uploaded it to the board. Here's the tiny little video wishing you merry christmas. Have a geeky one!