"OK so the MK1 show controller

was not a thing of beauty but was

what was needed for the time"

After years of planning, Learning and a house move it was finally time to started the prep for our first Christmas Light show, it all started in the summer of 2019 with finding a local person selling there light show on Facebook marketplace ( for some strange reason he wanted to rebuild a classic car ). so after going and picking up the Lights the size of the task hit me like a train. 

From the very beginning of planning I had decided that I didn't want to to run show every 10 minutes, 30 minutes or hourly I wanted people to be able to start a song at the push of a button that way there would not be crowds of people waiting (and upsetting the neighbour).

SO with that in mind I started to build, let's call it the MK0.5 show controller (The one that never came to be), a big red button that when pressed thought the magic of a customer server setup would pick a random song and play the show and then return the house to a stand-by.

But that year it was just not meant to be, the run up to Christmas was taken by a family trip to meet the Mouse him self at  Walt Disney World, so the light show went on hold until 2020.

Yep 2020 started as any other year over at my Mum and Dads and as far as we knew it at this point it was going to be a great year and this was the year the show was going up Christmas 2020 and the announcement went out on Facebook no excuses this year and then march hit, but work carried on and even more than ever I wanted the show running to bring some happiness to people.

With my desk covered in cable and circuit boards it was going well, we were expecting our second later in the year and both me and my wife had been stuck in the house since March (apart from hospital visits) as we were on the Highly Vulnerable list. when my Wife Maria comes up to me and says "I know you have been working on this for a while but just think about it" and with that I sat there and thought and thought some more and maybe  a bit more. 

Then it hit me NO ONE IS GOING TO WANT TO TOUCH A BUTTON 

And with that in mind the MK1 was born, OK so the MK1 show controller was not a thing of beauty but was what was needed for the time, a controller that was contactless so back on to Amazon (Prime was a god send in this time) and I ordered some part with no Idea how I was going to pull this thing off, but after some hard work and a lot of googleing I had a working prototype.

Brilliant it work but I can't put that outside, well as you can see in the video I was also in to 3D printing and that can in very handy, I set about on my largest design to date a enclosure for this mess I was calling "The Contactless Show Start".

Initial Case Design

Initial PCB and Firmware Design 

 

Fusion 360 Designs 

The Code  -> The story carries on below

// Disclaimer: Do not shoot lasers into your eyes or the eyes of others.
#include <ArduinoJson.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

////////////////////////////////////
// SSID and PASSWORD
////////////////////////////////////
const char* ssid     = "Skynet Global Defense Network";
const char* password = "";


///////////////////////////////////
// PIN ASSIGNMENTS
///////////////////////////////////
const int laserPin = D2;   // GPIO4 = board D2, via MOSFET
const int sensorPin = D1;  // GPIO5 = board D1
const int laserBrightness = 50; // Range is 0-1024, but really once you go higher than around 200, I couldn't notice a difference
const int GLED = D6; //GPIO12 = board D6, Ready to play LED 
const int RLED = D7; //GPIO13 = board D7, Playing LED 

///////////////////////////////////
// Default laser to not ready
///////////////////////////////////
bool laser_ready = false;

///////////////////////////////////
// SETUP
///////////////////////////////////

void setup() {
  pinMode(laserPin, OUTPUT);
  pinMode(GLED, OUTPUT);
  pinMode(RLED, OUTPUT);

  Serial.begin(9600);

  //// Start WiFi and wait for connection ////
    Serial.println("Starting WiFi");
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
          Serial.println("Waiting For WiFi to Connect");
          digitalWrite(GLED, HIGH); // LED on
          digitalWrite(RLED, LOW); // LED off
          delay(1000);
          digitalWrite(GLED, LOW); // LED off
          digitalWrite(RLED, HIGH); // LED on
    }
    
  Serial.println("WiFi has Connected");
  digitalWrite(GLED, HIGH); // LED on
  digitalWrite(RLED, LOW); // LED off
  Serial.println("System Ready");
}

///////////////////////////////////
// THIS FUNCTION IS CALLED WHEN THE BEAM IS BROKEN
///////////////////////////////////
void send_alarm_trigger() {

  Serial.println("Laser has been tripped");
  
  String service_URL = "http://192.168.0.27/api/command/";  

  Serial.println("Starting JSON");
  StaticJsonBuffer<200> jsonBuffer;
  char json[] = "{\"command\": \"Trigger Event\",\"args\": [\"1\",\"1\"]}";
  JsonObject& root = jsonBuffer.parseObject(json);
  if(!root.success()) {
    Serial.println("parseObject() failed");
  } else {
    Serial.println("JSON OK");
  }  
                         
  //Declare an object of class HTTPClient
    HTTPClient http;
    if (WiFi.status() == WL_CONNECTED) {
      //Specify request destination
      http.begin(service_URL);
      http.addHeader("Content-Type", "application/json");

      String data;
      root.printTo(data);
      //Send the request
      int httpCode = http.POST(data);

      //Check the returning code
      if (httpCode > 0) {
          //Get the request response payload
          String payload = http.getString();
          //Print the response payload
          Serial.println(payload);
      }
      
    //Close connection
    http.end();
    Serial.println(httpCode);
  }
}


///////////////////////////////////
// THIS FUNCTION MAKES SURE THE LASER
// IS AIMED AT THE SENSOR BEFORE ARMING
///////////////////////////////////
bool start_laser() {
  analogWrite(laserPin, laserBrightness);
  delay(50);
  if (!digitalRead(sensorPin)) {
    return true;
  }
  else {
    analogWrite(laserPin, 0);
    return false;
  }
}

///////////////////////////////////
// MAIN LOOP
///////////////////////////////////
void loop() {
  
  if (!laser_ready) {
    laser_ready = start_laser();
    delay(250);
  }

  if ((laser_ready) && (digitalRead(sensorPin))) {
    analogWrite(laserPin, 0);
    laser_ready = false;
    digitalWrite(GLED, LOW); // LED off
    digitalWrite(RLED, HIGH); // LED on
    
    send_alarm_trigger();    
    delay(240000);
    
    digitalWrite(GLED, HIGH); // LED on
    digitalWrite(RLED, LOW); // LED off
  }
}

The Final Product

It was a lot of work but it worked and it got use thought the 2020 show session 

Now days the MK1 spends it days hanging on the wall, reminding me that I can do this and to keep on improving the show.

And with it retirement well and truly under way, there was a need for a new Show Controller something a bit more reliable and water proof.

The MK1 is dead, long live the MK2 The MK2 Show Controller