Friday, May 8, 2015

The Police Siren Lights

How to build Police Siren Lights on an Arduino:
by J.B. Wylzan

Project 5:  Police Siren Lights:

This project turns on the 9 Leds where each breaks away from the center repeatedly 
just like the dividing lights seen on police cars.




Hardware:
9 LEDs
9 resistors 
connecting wires
breadboard
Arduino R3 UNO board

Schematic Diagram:




Block Diagram:





Code # 5:
/*
  iHackLab Police Siren Lights
  powered by Arduino
  sketched by J.B. Wylzan
  modified by Lawsinium

  Leds break away on both sides from the center continuously.
  This example code is public domain.
 */

 // Setup pins 4 to 12
void setup() 
 {
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
 }

// Turns LEDs On and Off from left to right repeatedly,
void loop() 
{
  
  digitalWrite(8, HIGH);   // turn the LED on 
  delay(100);
  digitalWrite(8, LOW);    // turn the LED off
  delay(100); 
  
  digitalWrite(7, HIGH);   // turn the LED on
  digitalWrite(9, HIGH);   // turn the LED on
   delay(100); 
  digitalWrite(7, LOW);    // turn the LED off 
  digitalWrite(9, LOW);    // turn the LED off
  
  digitalWrite(6, HIGH);   // turn the LED on
  digitalWrite(10, HIGH);   // turn the LED on
  delay(100);
  digitalWrite(6, LOW);    // turn the LED off
  digitalWrite(10, LOW);    // turn the LED off
  
  digitalWrite(5, HIGH);   // turn the LED on
  digitalWrite(11, HIGH);   // turn the LED on 
   delay(100);
  digitalWrite(5, LOW);    // turn the LED off
 digitalWrite(11, LOW);    // turn the LED off  

  digitalWrite(4, HIGH);   // turn the LED on 
  digitalWrite(12, HIGH);   // turn the LED on
  delay(100);
  digitalWrite(4, LOW);    // turn the LED off 
  digitalWrite(12, LOW);    // turn the LED off
}


Actual Layout:


Procedure:
1. Use the same prototype as shown above
2. Run the Arduino Interface
3. Select File > New
4. Copy Code #5 above
5. Paste Code #5
6. Click File > Save
7. Click Verify
8. Click Upload
9. Leds break away on both sides from the center continuously.

Be Creative:
Once you master the nuts and bolts in the Piezo Speaker project, go back to this page and add a police siren sound effect. Below is a partial sketch: 

int speakerPin = 3;
int numNotes = 8;
int notes[] = {1109, 523, 1109, 523, 1109, 523, 1109, 523};


Disclaimer:  We shall not be liable for any loss or damage of whatever nature - direct, indirect, consequential, or otherwise - which may arise as a result of your use of any information on this website. However, if you are interested in using any of the projects for personal or educational purposes, please inform the author by email. 

Public Domain Notice: Copyright (c) 2000. All rights reserved. This article is part of a book entitled iHackRobot. Copies are welcome to be shared or distributed publicly as long proper citations are observed. Please cite as follows: Biotronics: The Silver Species, Joey Lawsin, 1988, USA.

================================================================== 
The Homotronics® and Homodruinos® logos are registered trademarks.
Copyright Biotronics© Inc. iHackRobot®. All Rights Reserved.
Patent Pending. 2000 © ®

L.A.W.S.I.N. Educational Production
 ================================================================== 


No comments:

Post a Comment