Close
0%
0%

Motion detect Dalek

Uses a GCDuino (Gold Coast Techspace developed Arduino) with ultrasonic detection and directly plays a WAV file to PWM audio output

Similar projects worth following
Uses a GCDuino (uses Uno board selection in Arduino IDE). Uses a ping sensor HC-SR04 and triggers from 40cm - 120cm range.
GCDuino reads an SD card WAV file and outputs sound on pin 9 as PWM signal.
Have tried to simplify and lower cost of the project as much as possible and use what I had on hand.
Modified GCDuino to run on 3.3volts so no level shifter required for SD card - I used SD card adapter as a micro SD card reader.
This project is based on many similar Arduino-SD-Wav projects.
See http://youtu.be/QEcmZhScNJE for the final result

This project was shown at our local http://www.goldcoastsciencefair.com.au/ on the Gold Coast Australia
A great crowd draw .Suprised quite a few people walking past!

Still got to add schematic

  • 1 × GCDuino Similar to Uno
  • 1 × HC-SR04 Ultrasonic range sensor - less than $2 on ebay
  • 1 × LM2596 buck converter Convert 7-30volts in to 5volts for circuit - less than $2 on ebay
  • 1 × 3W class D amplifier PAM8403 mini board Amplify the Dalek voice! - less than $2 on ebay
  • 1 × Micro SD card adapter
  • 1 × Micro SD card I used a 128Meg (yes its an old card I had lying around) for this project
  • 2 × White USB bulbs Less than $5 on ebay
  • 3 × Blue LEDs

  • 1

    Breadboarding the setup

  • 2

    Uploading the program - this is the final version that plays all sounds then restarts

    Library files are from here  https://github.com/TMRh20/TMRpcm/wiki

    Note WAV files are 8bit and should be less than 20K/sec samples - I used Audacity Portable

    This is modified code originally from APC mag in Australia - the article goes into great detail 

    Thanks Darren Yates  http://apcmag.com/arduino-project-5-digital-audio-...

    // ---------------------------------------------------------------------------------
    // DO NOT USE CLASS-10 CARDS on this project - they're too fast to operate using SPI
    // ---------------------------------------------------------------------------------

    #include <SD.h>
    #include <TMRpcm.h>
    TMRpcm tmrpcm;

    File root;
    File entry;

    // ---------------------------------------------------------------------------------
    // set chipSelect to '10' if using the $2 SD card module or '4' if using the
    // Ethernet shield's microSD card instead.
    const int chipSelect = 10;
    // ---------------------------------------------------------------------------------

    const int oldCard = SPI_HALF_SPEED;
    const int newCard = SPI_QUARTER_SPEED;

    // ---------------------------------------------------------------------------------
    // set cardType to 'oldCard' if using an old SD card (more than a few years old) or
    // to 'newCard' if using a newly-purchase Class-4 card.
    int cardType = oldCard;
    // ---------------------------------------------------------------------------------

    int wasPlaying = 0;
    int inSwitch = 7;
    int finished = 0;
    int start = 0;
    int pauseOn = 0;
    int trigPin = 4;
    int echoPin = 5;

    void setup() {
    pinMode(trigPin, OUTPUT); //for HC-SR04
    pinMode(echoPin, INPUT); //for HC-SR04
    Serial.begin(9600);
    Serial.print("\nInitializing SD card...");
    pinMode(chipSelect, OUTPUT);
    if (!SD.begin(chipSelect,cardType)) {
    Serial.println("failed!");
    return;
    }
    Serial.println("done.");

    tmrpcm.speakerPin = 9; //Pin9 for audio output

    pinMode(inSwitch,INPUT_PULLUP); //Audio Test switch
    // digitalWrite(inSwitch,HIGH);

    root = SD.open("/");
    }

    void loop(void) {
    long duration, distance; //
    digitalWrite(trigPin, LOW); // HC-SR04 setup
    delayMicroseconds(2);
    digitalWrite(trigPin, HIGH);
    delayMicroseconds(20);
    digitalWrite(trigPin, LOW);
    duration = pulseIn(echoPin, HIGH); //Get ping time
    Serial.println(duration);
    boolean btnState = digitalRead(inSwitch); //Check Audio Test switch
    if(btnState == LOW){ //manual trigger on pin 7 - bring low
    playNext();
    delay(100);
    }
    if ((duration < 8000) && (duration > 3000)) { // Trigger set for 40cm - 120cm
    playNext();
    delay(5000); //Delay between each sound file
    }
    delay(1000); //Check ping sensor every second
    }


    void playNext() { //play next track function
    entry = root.openNextFile();
    Serial.println(entry);
    if (entry) {
    entry.close();
    tmrpcm.play(entry.name());
    wasPlaying = 1;
    } else {
    if (wasPlaying == 1) {
    wasPlaying = 0;
    root.rewindDirectory();
    entry = root.openNextFile();
    Serial.println(entry);
    entry.close();
    tmrpcm.play(entry.name());
    }
    }
    }

View all instructions

Enjoy this project?

Share      

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates