Arthur Sobel
Published © LGPL

Photon Animator Board

Particle Photon with DFPlayer along with animatronic drivers for Gemmi Frogz, Furby, Billy Bass, and other creatures.

IntermediateWork in progress10 hours1,043
Photon Animator Board

Things used in this project

Hardware components

Photon
Particle Photon
×1
DFRobot DFPlayer
×1
STMicroelectronics L9110H
×1
MPSA13
×1
PAM8403
×1
PCBWay Custom PCB
PCBWay Custom PCB
https://www.pcbway.com/project/shareproject/W53394ASF1_spark_fisha.html
×1
Resistor 10k ohm
Resistor 10k ohm
×3
22K ohm resistor
×3
33K resistor
×3

Story

Read more

Schematics

Pdf File for design

Code

02_blynk_DFPlayer

Arduino
Using Particle photon, DFPlayer, along with the Blynk graphical IOT platform
/*************************************************************
  Blynk is a platform with iOS and Android apps to control
  Arduino, Raspberry Pi and the likes over the Internet.
  You can easily build graphic interfaces for all your
  projects by simply dragging and dropping widgets.

    Downloads, docs, tutorials: http://www.blynk.cc
    Sketch generator:           http://examples.blynk.cc
    Blynk community:            http://community.blynk.cc
    Follow us:                  http://www.fb.com/blynkapp
                                http://twitter.com/blynk_app

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************

  No coding required for direct digital/analog pin operations!

 *************************************************************/

#define BLYNK_PRINT Serial  // Set serial output for debug prints
//#define BLYNK_DEBUG       // Uncomment this to see detailed prints

#include <blynk.h>
#include "DFRobotDFPlayerMini.h"
DFRobotDFPlayerMini myDFPlayer;
WidgetLED led1(V3);
BlynkTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "d26797d1efd7401fb18713ca41e25ef6";
boolean  froggymotion = false;
boolean  froggyarms = false;
int INApin = 0;
int INBpin = 1;
int TAILpin = 2;
int HEADpin = 3;
int ASSpin = 4;
int MRSTpin = 5;
int MSTBpin = 6;
int MOTIONpin = 7;

int advertnumber =1;
int trackset=1;
int oldstate=0;
int newstate =0;
int froggymotiontime =0;

void setup()
{
    Serial1.begin(9600);
    Serial.begin(115200);
    Serial.println();
    Serial.println(F("DFRobot DFPlayer Mini Demo"));
    Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
    
    pinMode(INApin, OUTPUT);
    pinMode(INBpin, OUTPUT);
    pinMode(TAILpin, OUTPUT);
    pinMode(HEADpin, OUTPUT);
    pinMode(ASSpin, OUTPUT);
    
      if (!myDFPlayer.begin(Serial1)) {  // use Serial1 to communicate with mp3.
          Serial.println(F("Unable to begin:"));
          Serial.println(F("1.Please recheck the connection!"));
          Serial.println(F("2.Please insert the SD card!"));
          while(true);
    }
    
    delay(4500); // Allow board to settle
    
    Serial.println(F("DFPlayer Mini online."));
      
      myDFPlayer.setTimeOut(500); //Set serial communictaion time out 500ms
      
      //----Set volume----
      myDFPlayer.volume(10);  //Set volume value (0~30).
      myDFPlayer.volumeUp(); //Volume Up
      myDFPlayer.volumeDown(); //Volume Down
      
      //----Set different EQ----
  myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
  myDFPlayer.loopFolder(6);
  


  Blynk.begin(auth);
  timer.setInterval(1000L, blinkLedWidget);  // one second interval
}


void blinkLedWidget(){   // 1 second interrupt 

	newstate = digitalRead(WKP);

  	if (newstate ==1) {			//if the pin is high the DFPlayer is not playing
	Serial.println("LED on V1: off");
	//froggymotion = false;
	digitalWrite(HEADpin, LOW);
	digitalWrite(INApin, LOW);
	digitalWrite(INBpin, LOW);
	if (oldstate == 0) led1.off();
  	} 
  else {
    led1.on();
    if (oldstate == 1) {
    Serial.print(newstate); 
    Serial.print(oldstate);
    Serial.println(" LED on V1: on");
    }
    if (froggymotion==true) { 

    	Serial.print(froggymotiontime);
    	Serial.println("froggymotion");
    	digitalWrite(HEADpin, HIGH);
    	if (froggyarms == true){
		digitalWrite(INApin, HIGH);
    		digitalWrite(INBpin, LOW);
    		}
    	else {
  		digitalWrite(INApin, LOW);
    		digitalWrite(INBpin, HIGH);
    		}  
    	froggyarms = !froggyarms;
    	
    	if (froggymotiontime++ >15) {
    		froggymotion = false;
    		froggymotiontime =0;
    		digitalWrite(INApin, LOW);
    		digitalWrite(INBpin, LOW);
    		digitalWrite(HEADpin, LOW);
    		}
    
  		}
	}
	oldstate = newstate;
}


// Attach a Step widget  and play files in folder 0 = mp3 folder 01-99 are normal folders 
BLYNK_WRITE(V4) {
      trackset = param.asInt();\

    	if (trackset == 0 )  myDFPlayer.enableLoopAll(); //loop all mp3 files.
    	//if (trackset < 0 ) trackset =99;
    	else  myDFPlayer.loopFolder(trackset);	
    	Serial.print(trackset) ;
    	Serial.println(F(" Loop track"));
    }


// Attach a Button widget (mode: Push) to the Virtual pin 1 - and advertise!  advertise turns on the frog 
BLYNK_WRITE(V1) {
    if (param.asInt() == 1) { // On button down...
        myDFPlayer.advertise(advertnumber);
        if (advertnumber++ > 18) {
        advertnumber = 1;
            }
        froggymotion = true ;
        }
        
    }


// Attach a slider to  Virtual pin 2 - and control the volume!
BLYNK_WRITE(V2) {
	int volset = param.asInt();
	myDFPlayer.volume(volset);
   
	}

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

Credits

Arthur Sobel

Arthur Sobel

4 projects • 4 followers
General electronics

Comments