Evil Baby - project afgerond
2 berichten
• Pagina 1 van 1
Evil Baby - project afgerond
Met dank aan behoorlijk wat mensen, die hebben meegeholpen, tips hebben gegeven, etc, etc... mijn Halloween prop!
Nog steeds niet perfect, geluid en audio gaan feitelijk langer door dan dat ik wil, en de sensor reageert ook niet altijd even goed... maar voor dit moment (morgen is het feestje) goed genoeg
https://youtu.be/FSVBEEtiLHU
In de pop zitten 2 gewone LEDs, weerstandjes, een Arduino UNO, Audio shield. De PIR-sensor zit op de buik.
Nogmaals dank allemaal! 't Was een hele bevalling
Voor de geïnteresseerden is hier de sketch:
#include <ISD1700.h>
///////Visuals//////
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;
//the time when the sensor outputs a high impulse
long unsigned int highIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 15000;
int pirPin = 3; //the digital pin connected to the PIR sensor's output
int ledPin = 4;
int ledPin2 = 5; //LET OP! Ik heb deze op 11 gezet, aangezien 10 wordt gebruikt door de audio! Geen idee of dit zomaar kan, wellicht moet je het anders aansluiten...
//////Audio//////
ISD1700 chip(10); // Initialize chipcorder with
// SS at Arduino's digital pin 10
int apc=0;
int vol=0; //volume 0=MAX, 7=min
int startAddr=0x10;
int endAddr =0x2DF;
long unsigned int startPlaytime;
long unsigned int totalPlaytime = 15000; // uitgaande van een opname van 5sec
/////////////////////////////
//SETUP
void setup(){
apc = apc | vol; //D0, D1, D2
apc = apc | 0x50; // D4& D6 select MIC REC
apc = apc | 0x80; // D7 AUX ON, comment enable AUD
apc = apc | 0x100; // D8 SPK OFF, comment enable SPK
apc = apc | 0x800; // D11 EOM ON, comment disable EOM
Serial.begin(9600);
Serial.println("Sketch is starting up");
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
digitalWrite(pirPin, LOW);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
////////////////////////////
//LOOP
void loop(){
//trigger to start when motion is detected
if(digitalRead(pirPin) == HIGH){
highIn = millis();
Serial.println("---");
Serial.print("motion detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");
//geen idee of een power up nodig is...
chip.pu();
startPlaytime = highIn;
chip.play();
//until a 'pause' window is detected, keep repeating on/off switches with delays
//delay can be increased to make the blinking less frequently
while (millis() - highIn < pause) {
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin2, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin2, LOW);
delay(50);
if(digitalRead(pirPin) == HIGH){
highIn = millis();
}
//mijn vermoeden is dat de audio stopt met spelen na de opgenomen tijd is bereikt. Neem aan dat je wil dat de audio in een loop blijft spelen...
if (highIn - startPlaytime > totalPlaytime) {
startPlaytime = highIn;
chip.play();
}
}
chip.stop();
Serial.print("motion ended at "); //output
Serial.print((millis() - pause)/1000);
Serial.println(" sec");
delay(50);
}
}
Nog steeds niet perfect, geluid en audio gaan feitelijk langer door dan dat ik wil, en de sensor reageert ook niet altijd even goed... maar voor dit moment (morgen is het feestje) goed genoeg
https://youtu.be/FSVBEEtiLHU
In de pop zitten 2 gewone LEDs, weerstandjes, een Arduino UNO, Audio shield. De PIR-sensor zit op de buik.
Nogmaals dank allemaal! 't Was een hele bevalling
Voor de geïnteresseerden is hier de sketch:
#include <ISD1700.h>
///////Visuals//////
//the time we give the sensor to calibrate (10-60 secs according to the datasheet)
int calibrationTime = 30;
//the time when the sensor outputs a high impulse
long unsigned int highIn;
//the amount of milliseconds the sensor has to be low
//before we assume all motion has stopped
long unsigned int pause = 15000;
int pirPin = 3; //the digital pin connected to the PIR sensor's output
int ledPin = 4;
int ledPin2 = 5; //LET OP! Ik heb deze op 11 gezet, aangezien 10 wordt gebruikt door de audio! Geen idee of dit zomaar kan, wellicht moet je het anders aansluiten...
//////Audio//////
ISD1700 chip(10); // Initialize chipcorder with
// SS at Arduino's digital pin 10
int apc=0;
int vol=0; //volume 0=MAX, 7=min
int startAddr=0x10;
int endAddr =0x2DF;
long unsigned int startPlaytime;
long unsigned int totalPlaytime = 15000; // uitgaande van een opname van 5sec
/////////////////////////////
//SETUP
void setup(){
apc = apc | vol; //D0, D1, D2
apc = apc | 0x50; // D4& D6 select MIC REC
apc = apc | 0x80; // D7 AUX ON, comment enable AUD
apc = apc | 0x100; // D8 SPK OFF, comment enable SPK
apc = apc | 0x800; // D11 EOM ON, comment disable EOM
Serial.begin(9600);
Serial.println("Sketch is starting up");
pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
digitalWrite(pirPin, LOW);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for(int i = 0; i < calibrationTime; i++){
Serial.print(".");
delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
delay(50);
}
////////////////////////////
//LOOP
void loop(){
//trigger to start when motion is detected
if(digitalRead(pirPin) == HIGH){
highIn = millis();
Serial.println("---");
Serial.print("motion detected at ");
Serial.print(millis()/1000);
Serial.println(" sec");
//geen idee of een power up nodig is...
chip.pu();
startPlaytime = highIn;
chip.play();
//until a 'pause' window is detected, keep repeating on/off switches with delays
//delay can be increased to make the blinking less frequently
while (millis() - highIn < pause) {
digitalWrite(ledPin, HIGH);
digitalWrite(ledPin2, HIGH);
delay(50);
digitalWrite(ledPin, LOW);
digitalWrite(ledPin2, LOW);
delay(50);
if(digitalRead(pirPin) == HIGH){
highIn = millis();
}
//mijn vermoeden is dat de audio stopt met spelen na de opgenomen tijd is bereikt. Neem aan dat je wil dat de audio in een loop blijft spelen...
if (highIn - startPlaytime > totalPlaytime) {
startPlaytime = highIn;
chip.play();
}
}
chip.stop();
Serial.print("motion ended at "); //output
Serial.print((millis() - pause)/1000);
Serial.println(" sec");
delay(50);
}
}
Advertisement
- Gij Kieken
- Berichten: 631
- Geregistreerd: 15 Nov 2015, 11:54
Re: Evil Baby - project afgerond
Brrr...scary
2 berichten
• Pagina 1 van 1
Terug naar Afgeronde projecten
Wie is er online?
Gebruikers in dit forum: Geen geregistreerde gebruikers en 2 gasten