Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
luseira
Published © CC BY-NC

Timecode Lightbox

Timecode triggered wireless light box.

IntermediateFull instructions provided948
Timecode Lightbox

Things used in this project

Hardware components

Arduino Pro Mini 328 - 3.3V/8MHz
SparkFun Arduino Pro Mini 328 - 3.3V/8MHz
The LoRa module I'm using is a 3,3V model, If you use a 5V Arduino, make sure to use 5V to 3,3V logic level converters.
×2
Arduino Nano R3
Arduino Nano R3
×1
Semtech LoRa SX1278
×2
3 mm LED: Red
3 mm LED: Red
×2
Vishay P-Channel Power MOSFET
×1
DC/DC Converter, Step Down
DC/DC Converter, Step Down
×1
Toggle Switch, Toggle
Toggle Switch, Toggle
×2
Toggle Switch, SPDT
Toggle Switch, SPDT
×1
XL6009 Step Up Converter
×1
Perfboard 5x10cm
×2
DC jack
×1
Micro USB Jack
×1
BNC Female Panel Mount
×2
Buzzer
Buzzer
×1
LED Strip
×1
22 AWG solid wire
×1
Through Hole Resistor, 1.5 kohm
Through Hole Resistor, 1.5 kohm
×1
Resistor 10k ohm
Resistor 10k ohm
×4
Tantalum Capacitor, 1 µF
Tantalum Capacitor, 1 µF
×1
Tantalum Capacitor, 10 µF
Tantalum Capacitor, 10 µF
×1
Capacitor 100 nF
Capacitor 100 nF
×1
9V Battery Clip
9V Battery Clip
×1

Hand tools and fabrication machines

Multimeter

Story

Read more

Custom parts and enclosures

TC Lightbox - transmitter cover

This is the top part of the transmitter enclosure

TC Lightbox - transmitter base

This is the base of the transmitter enclosure

TC Lightbox - receiver cover

This is the top part of the receiver

TC Lightbox - receiver base

This is the base of the receiver

Schematics

TC Lightbox - transmitter schematics

TC Lightbox - receiver schematics

Code

TC Lightbox - transmitter

C/C++
#include <SPI.h>
#include <LoRa.h>

// Define the number of samples to keep track of. The higher the number, the
// more the readings will be smoothed, but the slower the output will respond to
// the input. Using a constant rather than a normal variable lets us use this
// value to determine the size of the readings array.
const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int inputPin = A0;              // pino em que está conectado o TC

//variables
int counter = 0;
const int pinoBotao = 4;
const int ligaBotao = 2;
const int led = 8;
int statusBotao = 0;

// starts setup
void setup() {

  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;

    //Ins and outs
    pinMode(pinoBotao, INPUT);
    pinMode(ligaBotao, OUTPUT);
    pinMode(led, OUTPUT);

    //starts the serial port
    Serial.begin(9600);
    while (!Serial);

    Serial.println("LoRa Sender");

    //check if the module is propperly connected
    if (!LoRa.begin(915E6)) {
      Serial.println("Starting LoRa failed!");
      while (1);
    }
  }
}

//starts the loop
void loop() {
 
  statusBotao = digitalRead(pinoBotao);
  digitalWrite(ligaBotao, HIGH);


  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(inputPin);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;

  if (average < 0)
  {
    average = - average;
  }
  // send it to the computer as ASCII digits

  // if there is TC on input A0
  if (average > 100)
  {
    //prints in the serial monitor
    Serial.println(average);
    // sends the packet
    LoRa.beginPacket();
    LoRa.print("1");
    LoRa.endPacket();
    digitalWrite (led, HIGH);
    delay(300);
  }

  // if there is no TC and the button is not pressed
  if  (average == 0 && statusBotao == LOW) {
    //prints on the serial monitor
    Serial.println("0");
    // sends the packet
    LoRa.beginPacket();
    LoRa.print("0");
    LoRa.endPacket();
    digitalWrite (led, LOW);
    delay(300);
  }
  delay(10);        // delay in between reads for stability


  // if the button is pressed, sends the message "1"
  if (statusBotao == HIGH)
  {
    //prints on the serial monitor
    Serial.println("1");
    // sends the packet
    LoRa.beginPacket();
    LoRa.print("1");
    LoRa.endPacket();
    digitalWrite (led, HIGH);
    delay(100);
  }


}

TC Lightbox - receiver

C/C++
#include <SPI.h>
#include <LoRa.h>

// variables
int LED = 5;
int MOSFET = 4;
int buzzer = 3;
char msg;
int msgAtual = 0;
int msgAntiga = 0;

// starts setup
void setup() {

// Ins and outs

  pinMode(LED, OUTPUT);
  pinMode(MOSFET, OUTPUT);
  pinMode(buzzer, OUTPUT);

// starts the serial monitor
  Serial.begin(9600);

  while (!Serial);
  Serial.println("LoRa Receiver");

//check if the module is propperly connected
  if (!LoRa.begin(915E6)) {
    Serial.println("Starting LoRa failed!");
    while (1);
  }
}

// starts the loop
void loop() {
  
  // try to receive a package
  int packetSize = LoRa.parsePacket();
  if (packetSize) {
    
    // if the package was received
    Serial.print("msg = ");

    // updates the variable with the value of LoRa.read   
    msg = (char)LoRa.read();

   //prints msg
    Serial.print(msg);
   
    // //prints the signal strenght (RSSI)
    Serial.print(", com RSSI ");
    Serial.println(LoRa.packetRssi());
    
  }

// section that commands the LED strip
// if the messagem is higher than 0 (or 48 em ASCII), turn ON the LED strip
  if (msg > 48){
    digitalWrite(MOSFET, HIGH);
  }

// sif not, turns it OFF
  else {
    digitalWrite(MOSFET, LOW);
  }

// seccion that controls the Buzzer
// defines msgAtualas msg
msgAtual = msg;

// compares if msgAtual equals msgAntiga
if (msgAtual != msgAntiga) {
  //if they ar not equal and e msg equals to 1 (stop >> rec)
 
  if (msgAtual == 49){
    tone(buzzer, 440);
    delay(100);
    noTone(buzzer);
  }  
  if (msgAtual == 48 && millis() > 1000){
    tone(buzzer, 261);
    delay(70);
    noTone(buzzer); 
    delay(100);
    tone(buzzer, 261);
    delay(70);
    noTone(buzzer);
  }  
  // a litle bit of delay...
    delay(50);
}

  //updates msgAntiga as msgAtual
  msgAntiga = msgAtual;
}

Credits

luseira
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.