Laurence Daxes
Published © MIT

Remote Doorbell with Custom (mp3) Song with Cayenne

By a button on a board connected to Internet, activates the sound of a melody (whose mp3 file you have selected) in another board.

IntermediateFull instructions provided2 hours1,649
Remote Doorbell with Custom (mp3) Song with Cayenne

Things used in this project

Story

Read more

Code

01-cayenne.ino

Arduino
Code on Particle Photon
#define CAYENNE_PRINT Serial
#include "cayenne-particle/cayenne-particle.h"

char auth[] = "nezswd70wi";
int ledPin = D7;
int btnPin = D6;


void setup()
{
    pinMode(ledPin, OUTPUT);
    pinMode(btnPin, INPUT);
    Serial.begin(9600);
    delay(5000); // Allow board to settle
    Blynk.begin(auth);
}

BLYNK_READ(V0){
    pinData = digitalRead(btnPin);
    Blynk.virtualWrite(V0,pinData);
}


BLYNK_WRITE(V0){ int currentValue = param.asInt(); // 0 to 1
  if (currentValue == 1) { 
      digitalWrite(ledPin, HIGH);
  } else { 
      digitalWrite(ledPin, LOW);
  }
}


void loop(){ Blynk.run(); }

LinkItONE-Ring.ino

Arduino
Code for LinkIt ONE
#include <LWiFi.h>
#include <LWiFiClient.h>
#define CAYENNE_DEBUG         // Uncomment to show debug messages
#define CAYENNE_PRINT Serial  // Comment this out to disable prints and save space
#include <CayenneLWiFiWpa.h>

#include <LSD.h>
#include <LAudio.h>

char token[] = "2fm04460o2";
char ssid[] = "MOVLAU";
char password[] = "l4ur3nc3.w1";

// Custom Widget
#define CAYENNE_PRINT Serial
#define VIRTUAL_PIN 1
#define LED_DIGITAL_PIN 12

#define file_name (char *)"iphone.mp3" 

void setup(){
  pinMode(LED_DIGITAL_PIN, OUTPUT);  
  Serial.begin(9600);
  LSD.begin();
  Cayenne.begin(token, ssid, password);
  LAudio.setVolume(5);
}

CAYENNE_IN(VIRTUAL_PIN){ 
  int currentValue = getValue.asInt(); // 0 to 1
  if (currentValue == 1) {     
    digitalWrite(LED_DIGITAL_PIN, HIGH);    
    Serial.print("Playing: ");
    Serial.println(file_name);
    LAudio.playFile(storageSD,file_name);
    delay(3000);
    LAudio.playFile(storageSD,file_name);
    delay(3000);
    LAudio.stop();
    digitalWrite(LED_DIGITAL_PIN, LOW);
    Cayenne.virtualWrite(1,LOW);
  } else { 
    LAudio.stop();
    digitalWrite(LED_DIGITAL_PIN, LOW);  
  }
}

void loop(){Cayenne.run();}

Credits

Laurence Daxes

Laurence Daxes

19 projects • 36 followers
Systems Engineer Bachellor, I Love technology, and IoT World https://youtube.com/c/DaxesHacks

Comments