Here is the code I used from the video. After exporting your Bottango code, copy and past this to the BottangoArduinoDriver.inoi tab at the top of your sketch. Of course you can alter any aspect of this to make it your own. If you want different head movements just reconnect to Bottango, create new animation, export Bottango code, and paste this same code to the same tab in the sketch Check out the description for links to previous videos no setting up your animation and using DFPlayer Mini module if you need it. 👍 //Pit Droid is motion activated for 30 sec with sound #include "src/BottangoCore.h" #include "src/BasicCommands.h" #include // Include the DFPlayer Mini library // Function prototypes void checkMotionSensor(); void manageTrackPlayback(); void triggerAnimation(); // Create a DFPlayer Mini object DFRobotDFPlayerMini mp3; // Pin definition for the motion sensor #define MOTION_SENSOR_PIN 6 // Motion detection variables bool motionDetected = false; unsigned long lastDetectionTime = 0; const unsigned long trackDuration = 30000; // 30 seconds duration for music playback after motion detection unsigned long trackEndTime = 0; // Time to end track play // Setup function void setup() { // Initialize the motion sensor pin as input pinMode(MOTION_SENSOR_PIN, INPUT);
// Start communication with the computer Serial.begin(115200); // For debugging, outputs to the Serial Monitor
// Initialize hardware serial (TX1/RX1) for DFPlayer Mini Serial1.begin(9600);
// Check if the DFPlayer Mini is correctly connected if (mp3.begin(Serial1)) { Serial.println("DFPlayer Mini is ready."); mp3.volume(20); // Set volume level (0-30) } else { Serial.println("Error: DFPlayer Mini not detected. Please check connections."); }
// Setup the BottangoCore BottangoCore::bottangoSetup(); } // Loop function void loop() { // Check for motion and manage track playback checkMotionSensor(); manageTrackPlayback();
// Run Bottango loop BottangoCore::bottangoLoop(); } // Function to check the motion sensor void checkMotionSensor() { bool currentMotion = digitalRead(MOTION_SENSOR_PIN) == HIGH; unsigned long currentTime = millis(); if (currentMotion && !motionDetected) { motionDetected = true; lastDetectionTime = currentTime; Serial.println("Motion detected. Triggering animation and music."); triggerAnimation(); trackEndTime = currentTime + trackDuration; // Set the time when the music should stop } } // Function to trigger animations and music void triggerAnimation() { BottangoCore::commandStreamProvider.startCommandStream(0, false); // Start default animation without looping mp3.randomAll(); // Play a random track from the SD card Serial.println("Music playback started."); } // Function to manage track playback based on motion detection void manageTrackPlayback() { unsigned long currentTime = millis(); if (currentTime >= trackEndTime && motionDetected) { Serial.println("30 seconds have passed since motion was detected. Stopping playback."); mp3.stop(); // Stop playback motionDetected = false; // Reset motion detection flag } }ua-cam.com/users/sgaming/emoji/7ff574f2/emoji_u1f44d.png
Hey there! I found a good spring that wasn't too stiff and wasn't too loose. The wire would snap after a few adjustments but the spring that's in there now is great! I guess if anything is placed in the head, like a board or speaker, we'd need a stiffer spring. But as of now, it's working well. It's also light enough that I can use 5v to power the servos without any trouble. I tried everything on this head animation. Went front redneck hardware quick fixes to recommended parts. It was fun. ready for another one!
This is awesome, I’m so glad you got it all together! Did I catch this right? The LEDs color and sequence are not controlled by Bottango? If so, why not - would a …. Curve? … work? Sorry, I can’t remember the correct term or if that curve is it. That is what I used when I made my crows eyes blink. Very thorough video of your set up, that is awesome that you did that because I’m sure it will help others, myself included.
Hey there, thanks! The LED on/off switch is controlled by Bottango while the pattern, blink speed, and color are controlled by the mini controller on the LED wire. It was easier for me to change the look of the LEDs whenever I want without connecting the board and changing code or bottango settings. I used Bottango to control the serovs and power to the LED, the motion sensor and mp3's are controlled by Arduino. I may not have been clear about that (oops). A curve may work, I'll have to try it. I have another one to build. I would like to make a controller for it, use xbee or maybe some cheaper bluetooth modules. We'll see. I think it will be fun to come back to this every once in a while with some different builds.. Thanks for leaving a comment. Much appreciated !! 👍
@@BMonsterLaboratory no, you were clear in the explanation, and the reasoning makes perfect sense. Happy to comment, helps create community and supports each other’s work.
Here is the code I used from the video. After exporting your Bottango code, copy and past this to the BottangoArduinoDriver.inoi tab at the top of your sketch. Of course you can alter any aspect of this to make it your own. If you want different head movements just reconnect to Bottango, create new animation, export Bottango code, and paste this same code to the same tab in the sketch Check out the description for links to previous videos no setting up your animation and using DFPlayer Mini module if you need it. 👍
//Pit Droid is motion activated for 30 sec with sound
#include "src/BottangoCore.h"
#include "src/BasicCommands.h"
#include // Include the DFPlayer Mini library
// Function prototypes
void checkMotionSensor();
void manageTrackPlayback();
void triggerAnimation();
// Create a DFPlayer Mini object
DFRobotDFPlayerMini mp3;
// Pin definition for the motion sensor
#define MOTION_SENSOR_PIN 6
// Motion detection variables
bool motionDetected = false;
unsigned long lastDetectionTime = 0;
const unsigned long trackDuration = 30000; // 30 seconds duration for music playback after motion detection
unsigned long trackEndTime = 0; // Time to end track play
// Setup function
void setup() {
// Initialize the motion sensor pin as input
pinMode(MOTION_SENSOR_PIN, INPUT);
// Start communication with the computer
Serial.begin(115200); // For debugging, outputs to the Serial Monitor
// Initialize hardware serial (TX1/RX1) for DFPlayer Mini
Serial1.begin(9600);
// Check if the DFPlayer Mini is correctly connected
if (mp3.begin(Serial1)) {
Serial.println("DFPlayer Mini is ready.");
mp3.volume(20); // Set volume level (0-30)
} else {
Serial.println("Error: DFPlayer Mini not detected. Please check connections.");
}
// Setup the BottangoCore
BottangoCore::bottangoSetup();
}
// Loop function
void loop() {
// Check for motion and manage track playback
checkMotionSensor();
manageTrackPlayback();
// Run Bottango loop
BottangoCore::bottangoLoop();
}
// Function to check the motion sensor
void checkMotionSensor() {
bool currentMotion = digitalRead(MOTION_SENSOR_PIN) == HIGH;
unsigned long currentTime = millis();
if (currentMotion && !motionDetected) {
motionDetected = true;
lastDetectionTime = currentTime;
Serial.println("Motion detected. Triggering animation and music.");
triggerAnimation();
trackEndTime = currentTime + trackDuration; // Set the time when the music should stop
}
}
// Function to trigger animations and music
void triggerAnimation() {
BottangoCore::commandStreamProvider.startCommandStream(0, false); // Start default animation without looping
mp3.randomAll(); // Play a random track from the SD card
Serial.println("Music playback started.");
}
// Function to manage track playback based on motion detection
void manageTrackPlayback() {
unsigned long currentTime = millis();
if (currentTime >= trackEndTime && motionDetected) {
Serial.println("30 seconds have passed since motion was detected. Stopping playback.");
mp3.stop(); // Stop playback
motionDetected = false; // Reset motion detection flag
}
}ua-cam.com/users/sgaming/emoji/7ff574f2/emoji_u1f44d.png
great great stuff
Thanks! Lots of adjustments and changes made throughout this process. Thanks for leaving comments- much appreciated!
Looks great. I see you aren't using the wire anymore and went back to a spring? Did that end up being more stable?
Hey there! I found a good spring that wasn't too stiff and wasn't too loose. The wire would snap after a few adjustments but the spring that's in there now is great! I guess if anything is placed in the head, like a board or speaker, we'd need a stiffer spring. But as of now, it's working well. It's also light enough that I can use 5v to power the servos without any trouble.
I tried everything on this head animation. Went front redneck hardware quick fixes to recommended parts. It was fun. ready for another one!
This is awesome, I’m so glad you got it all together!
Did I catch this right? The LEDs color and sequence are not controlled by Bottango? If so, why not - would a …. Curve? … work?
Sorry, I can’t remember the correct term or if that curve is it. That is what I used when I made my crows eyes blink.
Very thorough video of your set up, that is awesome that you did that because I’m sure it will help others, myself included.
Hey there, thanks! The LED on/off switch is controlled by Bottango while the pattern, blink speed, and color are controlled by the mini controller on the LED wire. It was easier for me to change the look of the LEDs whenever I want without connecting the board and changing code or bottango settings. I used Bottango to control the serovs and power to the LED, the motion sensor and mp3's are controlled by Arduino. I may not have been clear about that (oops).
A curve may work, I'll have to try it. I have another one to build. I would like to make a controller for it, use xbee or maybe some cheaper bluetooth modules. We'll see. I think it will be fun to come back to this every once in a while with some different builds..
Thanks for leaving a comment. Much appreciated !! 👍
@@BMonsterLaboratory no, you were clear in the explanation, and the reasoning makes perfect sense.
Happy to comment, helps create community and supports each other’s work.
The Droid Division and Bottango groups are great to talk to. They both have a great community of users that are always helpful.