Average Ticker

Wemos D1 Mini Police Project

Wemos Police ProjectThe Fuzz. The Po-Po. The Rozzers. The 5-0. What do you call the police?

“HANDS UP!”…”GET ON THE GROUND NOW!”…”DON’T MOVE OR I’LL KICK YOUR ASS!”

Ah yes, classic lines from some of my favourite cop shows. The drama and excitement of policing is fun to watch from afar, but I don’t think I’ve got the plums to do that job myself.

For those of us hiding in the safety of our living rooms, there is a way to feel like you’re riding the ‘blues and twos’…albeit a bit of a nerdy way…

Let’s make a badass crime-busting police car project with the Wemos D1 Mini, some LEDs and buzzers!

Getting into Character

We can’t do this whilst we still feel like helpless civilians, so I refer you to my brother from another mother KRS-One to get you into street cop mode *whoop whoop*:

What We’re Making

This project hooks up two buzzers and LEDs, and with some simple code it’ll make sounds and lights just like a bank-robber-chasing meat wagon.

The buzzers make use of a nifty Arduino ‘tone’ command which makes it easy to pump different tones out of the buzzers.

Here’s a video showing my finished project in action (it’s noisy, careful now!):

What You’ll Need

This is a nice simple project, requiring readily available and affordable parts:

Wemos police project parts
A few simple everyday components are all you need

How to make it

Here’s a Fritzing diagram showing how I have my circuit hooked up:


Thanks to Fritzing.org for the fantastic software

Here’s my breadboard project to give you an idea of what that looks like in real life:

Wemos police project breadboard
I use two buzzers to pump out two tones at once, which creates the ear-splitting ‘nee naw‘ you hear flying past you.

So it’s simple enough – each of the LEDs has the negative leg going from GND through a resistor, and the positive leg runs to a GPIO pin. The buzzers are the same just without the resistors. Easy!

Some pointers:

  • Buzzers have a set polarity (+ and -). Any half-decent buzzer should have a longer positive leg just like an LED, and should also have a ‘+’ printed on the top.
  • LEDs also have a set polarity of course. The longer leg is the positive (+) leg. Get this wrong and you’ll kill your LED.
Buzzer legs
Like LEDs, buzzers usually have a longer leg for the positive terminal

How to Code it

If you haven’t yet set up your Wemos D1 Mini in the Arduino IDE – check out my post on that here.

We’re going to be turning the GPIO pins on/off to make our LEDs mimic a hot persuit in action.

We’re also using the Arduino ‘tone’ command to produce a different tone for each buzzer. This should give us the unmistakeable ‘nee naw‘ sound of the fuzz.

Here’s the example code which is used in the video above. Check out the comments for tips, and play around with different tones until you’re happy with it (see tone codes at the end of this page):

// This initial section gives our GPIO pins some familiar names for use later on
// Don't forget that Wemos GPIO pins don't use the board numbering in code.
// For example, the D5 you see on the Wemos is actually GPIO 14.
// See the Wemos pinout for more info: https://wiki.wemos.cc/products:d1:d1_mini

int LED1 = 16; // D0
int LED2 = 14; // D5
int Buzzer1 = 12; // D6
int Buzzer2 = 13; // D7

// the setup function runs ONCE when you press reset or power the board
void setup() {
  
  // initialize digital pins as outputs:
  pinMode(LED1, OUTPUT); 
  pinMode(LED2, OUTPUT);
  pinMode(Buzzer1, OUTPUT);
  pinMode(Buzzer2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {

  // Both buzzers play tones and LED1 turns on. LED 2 is turned off:
  tone(Buzzer1,370); //(F#4 note)
  tone(Buzzer2,466); //(A#4 note)
  digitalWrite(LED1, HIGH);
  digitalWrite(LED2, LOW);

  // Wait half a second
  delay(500);

  // Both buzzers play different tones and LED2 turns on. LED 1 is turned off:
  tone(Buzzer1,415); //(G#4 note)
  tone(Buzzer2,494); //(B4 note)
  digitalWrite(LED1, LOW);
  digitalWrite(LED2, HIGH);

  // Wait half a second
  delay(500);  
}

Where to use it

Whatever you do with this, I think it’s an easy and engaging beginner project for kids or new makers. I hadn’t done much with buzzers previously, so I used this as a fun way to learn (whilst also learning about the handy Arduino tone command).

I like the thought of integrating it into a police-bot – a police-themed robot project with something like this sitting on top. People keep making the same old robot projects without any thought for theme or style.

How about a bedroom alarm? Your little brother won’t snoop around your room if you have this going off (in conjunction with a PIR sensor). You could even take advantage of the Wemos’ built-in WiFi to alert your phone when it triggers!

Now go catch the bad guys!

Rich

3 Comments on "Wemos D1 Mini Police Project"

  1. Ben Scarboro | 10/03/2019 at 10:27 | Reply

    Love it. Gotta try these little boards out.
    Still laughing from “Remove seal after washing” label on the buzzers, not the first time I’ve seen that 🙂

Leave a comment

Your email address will not be published.


*


This website uses cookies. Please visit our privacy policy page for more information. Privacy policy

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close