Makestreme
Published © GPL3+

AI Scarecrow - Makes Noise When It Sees Birds

Pigeons kept making my balcony dirty, so I made a scarecrow with an AI camera that makes noises when it sees birds.

IntermediateFull instructions provided4 hours207
AI Scarecrow - Makes Noise When It Sees Birds

Things used in this project

Hardware components

Seeed studio Grove vision AI module v2
×1
pam8403 audio amplifier
×1
Speaker: 3W, 4 ohms
Speaker: 3W, 4 ohms
×1

Software apps and online services

Arduino IDE
Arduino IDE
Seeed Studio sensecraft AI

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

AI noise maker

Arduino
Code to be uploaded to Xiao and then connected to AI module
#include <Seeed_Arduino_SSCMA.h>

#define AUDIO_PIN D1

SSCMA Infer;

bool locked = false; 

// Time settings
const int minFreq = 2000;  // Minimum frequency (2 kHz) 
const int maxFreq = 20000; // Maximum frequency (20 kHz)
const int pulseDuration = 100; // Duration of each pulse (ms)
const int pulseInterval = 200; // Interval between pulses (ms)

void makeNoise() {
  // Generate a random frequency between minFreq and maxFreq
  int frequency = random(minFreq, maxFreq);

  // Generate a short pulse at the random frequency
  tone(AUDIO_PIN, frequency, pulseDuration);

  // Wait for the pulse interval before the next one
  delay(pulseInterval);

  // Stop the sound briefly to create a gap (quiet time between pulses)
  noTone(AUDIO_PIN);

  // Wait before generating the next pulse with a different frequency
  delay(random(10, 100)); // Random delay for randomness in pulsing pattern
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Scanning...");

  pinMode(AUDIO_PIN, OUTPUT);
}

void loop() {s
  // put your main code here, to run repeatedly:
  if (!Infer.invoke()) {
    if (Infer.boxes().size() > 0) {
      makeNoise();
    }
    else{
      noTone(AUDIO_PIN);
    }
  }
}

Credits

Makestreme
9 projects • 10 followers
I make DIY projects that are fun and interesting! An engineer by profession :) youtube.com/@makestreme

Comments