3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Arduino Police Lights (ATMega 2650 Version)

Arduino Police Lights (ATMega 2650 Version)
As promised, this is the ATMega 2650 version of the police lights I originally did on my Duemilanove. 

What you will need:

8x red LED's (high brightness) You will want extra bright red LED's because the ones I used are not very bright compared to the blue
8x blue LED's (high brightness)
16x 100 ohm resistors
1x ATMega 2650
22AWG wire
1x breadboard

I did not use resistors with my MEGA police lights, but feel free to use them so you don't burn out your LED's.

Optional: 
You can use transistors to use a lot of lights and not have to have as much code, or as many outputs being used. Just replace the LED's with the transistors you want to use.

Or even use shift registers and have a HELL of a lot of LED's hooked up.
 
Remove these adsRemove these ads by Signing Up
 

Step 1The Hardware

The Hardware
«
  • DSC_3087.JPG
  • DSC_3086.JPG
  • DSC_3088.JPG
The final result:


Considering you have installed the MEGA drivers and can program it, I will show you how to make awesome looking police lights.

First, you want to grab your breadboard, and some wire. You want to have it hooked up similar to the way I have it hooked up I the first picture. This makes it look better, stay together better, and make it easier to hook it up.

You will notice that the way I hooked it up looks a little weird, don't fret. I have it programmed to use these pins so you don't have to figure them all out.

I know I don't provide a schematic, but it would be a HUGE pain to draw one up, and it would not look very good or understandable with this many outputs. I figured you can see how to hook it up enough to actually hook it up. Follow my Duemilanove version if you can't figure this out. This is just double the outputs of what that is.
« Previous StepDownload PDFView All StepsNext Step »
3 comments
Feb 9, 2012. 10:22 AMSayntCigol says:
/*
This is a 16 LED police light sketch to be used with the MEGA.
Hook up each line of LED's to a breadboard properly and it'll
look amazing!

This Code is much easier to read / modify if desires change.
*/

void setup() {
// Give all LED-pins OUTPUT status
// Pin 23-37 is Red, 39-53 is Blue
for(int i=23; i<54; i+=2) {
pinMode(i, OUTPUT);
int RedLEDs[] = {23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37};
int BlueLEDs[] = {39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 52, 52, 53};
}
}

void loop() {
// Flash the LEDs in series of 6, alternating the color 3 times
for(int i=0; i<3; i++) {
flashLED(6, BlueLEDs);
flashLED(6, RedLEDs);
}

// Flash the LEDs in series of 2, alternating the color 5 times
for(int i=0; i<5; i++) {
flashLED(2, BlueLEDs);
flashLED(2, RedLEDs);
}
}

void flashLED(int times, int LEDPins[15]) {
for(int i=0; i for(int pin=0; pin<15; pin++) {
digitalWrite(LEDPins[pin], HIGH);
}
delay(50);
for(int pin=0; pin<15; pin++) {
digitalWrite(LEDPins[pin], LOW);
}
}
}

}
Jan 26, 2012. 2:08 PMgarfield1994 says:
How come you are not using any resistors for the LED's ?
Jan 21, 2012. 3:14 AMRHE123 says:
Interesting animation! Your code is quite long (as you say yourself) and I think this can be shortened a lot. So this is what I did. I was not able to actually test it (I don't have a mega available at the moment), but it should have the same output as your code. It can be even shorter, but than the readability would be worse. The code:
/*
This is a 16 LED police light sketch to be used with the MEGA.
Hook up each line of LED's to a breadboard properly and it'll
look amazing!
*/

void setup() {
  // Give all LED-pins OUTPUT status
  // Pin 23-37 is Red, 39-53 is Blue
  for(int i=23; i<54; i+=2) {
    pinMode(i, OUTPUT);
  }
}  

void loop() {
  // Flash the LEDs in series of 6, alternating the color 3 times
  for(int i=0; i<3; i++) {
    flashBlue(6);
    flashRed(6);
  }

  // Flash the LEDs in series of 2, alternating the color 5 times
  for(int i=0; i<5; i++) {
    flashBlue(2);
    flashRed(2);
  }
}

void flashBlue(int times) {
  for(int i=0; i<times; i++) {
    digitalWrite(37, HIGH);
    digitalWrite(35, HIGH);
    digitalWrite(33, HIGH);
    digitalWrite(31, HIGH);
    digitalWrite(29, HIGH);
    digitalWrite(27, HIGH);
    digitalWrite(25, HIGH);
    digitalWrite(23, HIGH);
   
    delay(50);
  }
}

void flashRed(int times) {
  for(int i=0; i<times; i++) {
    digitalWrite(53, HIGH);
    digitalWrite(51, HIGH);
    digitalWrite(49, HIGH);
    digitalWrite(47, HIGH);
    digitalWrite(45, HIGH);
    digitalWrite(43, HIGH);
    digitalWrite(41, HIGH);
    digitalWrite(39, HIGH);
   
    delay(50);
  }

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
8
Followers
5
Author:Wally_Z(My Youtube)
I like to tinker with electronics. I like to mod, hack, and learn how something works by taking it apart.