arduino uno led sequence with button need shematic

Reloadron

Joined Jan 15, 2015
7,890
The Arduino boards can be powered from 5 Volts USB as you see and also have an external power in connector which will accept 7 to ~12 Volts. Actually greater than 12 volts. The actual board has an on board 5 volt regulator which powers the board and makes 5 volts available as an output. So yes, you can power the board externally with 12 volts. The connector is a size K coaxial DC power plug commonly called a Barrel Size 5mm OD X 2.1mm ID. I run mine on either external DC off a wall wort or 5 volt USB power.

Get acquainted with the Arduino specifications.

Note that while 40 mA is mentioned I would not run much over 20 mA on any single D/O (Digital Output) pin. I really suggest you read and understand the specifications or I guarantee you will cook that chip.

I mentioned a few post back that if you want to drive a heavier load you use a transistor or a good choice for heavy loads are logic level MOSFETs. I also suggest for experimenting you get a small little bread board or proto board and a pile of little jumper wires if you do not already have them.

Ron
 

Thread Starter

a Rob

Joined May 14, 2017
151
i mean is before i build the prototype board or permenant board can i use a 12v power supply so it can be used in car or do i need converter 12v to 5v.


yes am willing to add extra resistors and mofset to archive my goal sir.

am currently searching for led chaser codes and manualy stripping out the code and making my own code and its working fine, am looking for police strobe code
 

shteii01

Joined Feb 19, 2010
4,644
i mean is before i build the prototype board or permenant board can i use a 12v power supply so it can be used in car or do i need converter 12v to 5v.


yes am willing to add extra resistors and mofset to archive my goal sir.

am currently searching for led chaser codes and manualy stripping out the code and making my own code and its working fine, am looking for police strobe code
You will need to convert 12V to 5V.
You can look in ATmega328 datasheet to see the absolute maximum voltage it will tolerate.
 

Reloadron

Joined Jan 15, 2015
7,890
i mean is before i build the prototype board or permenant board can i use a 12v power supply so it can be used in car or do i need converter 12v to 5v.


yes am willing to add extra resistors and mofset to archive my goal sir.

am currently searching for led chaser codes and manualy stripping out the code and making my own code and its working fine, am looking for police strobe code
No, the actual guts of your Arduino Uno have as mentioned a 5 Volt and 3.3 Volt regulator. If you program the chip (an Atmel Atmega 328P) the chip is a 5 Volt supply chip. I suggest you read the data sheet. So for use in an automotive application or any 12 VDC application you want a 5 Volt regulator which can be as simple as an old but reliable LM7805 5.0 Volt regulator. They cost about a buck (one US Dollar) each and only need a few cheap capacitors and you have your 5 Volts.

While it can be argued that the LM 7805 is not a good choice for automotive applications due to "load dumps" where voltage can spike upwards of 60 Volts I will still suggest it but there are other chips also suitable. I used 7805 chips in many automotive applications and never had a problem, including some old cars like a 1978 Pontiac. You can also Google 5 Volt Automotive Regulators for more options. The ancient LM 7805 comes in a handy TO-220 package making for easy mounting.

Last but not least every police car I have seen with a new light bar has a variety of sequences and additionally the sequences depend on where you are. For the most part they seem to like the "strobe" effects because they are attention grabbing, especially when one is behind you.

Ron
 

Thread Starter

a Rob

Joined May 14, 2017
151
the LM 7805 does that convert the power to 5v.
am in uk

so i have 8 leds 4 red 4 blue

this is how strobe in police car
left blink 3 seconds fast
then right blink 3 seconds fast
loop
but each left and right will blink with 4 leds each
 

Reloadron

Joined Jan 15, 2015
7,890
Yes, the LM 7805 is a voltage regulator. I gave you a link for the 78 Series including the 7805. The link to the data sheet provides schematics in the Application section. The thing only has three pins, Input, Output and Common. Read the data sheet links.

Your LEDs should have a data sheet or when you bought them they covered the working Forward Voltage and Forward Current. You need to figure your total current. The LEDs used in police car light bars are generally high intensity type LEDs which draw more current. I suggest you Google High Intensity LEDs for some ideas. I have no clue what the data sheet specifications are on your existing LEDs so I won't even guess how you should drive them. I also suggest you not place anything on a car, truck or any vehicle which may conflict with your local or national laws. Where you choose to place LEDs and the color schemes you choose are your doing. Here in the US there are actually automotive LED kits for decoration. I use a flashing red LED system for the brake light on my motorcycle but what I have is street legal in any of the 50 United States.

Ron
 

Thread Starter

a Rob

Joined May 14, 2017
151
no lol.
it will be small hand gadget u just power it on and press button and cycle led modes.
i want to know how to do the police amber blinking.

left blink 3 seconds fast
then right blink 3 seconds fast
loop

==============================
button question
how do i add a digital display small one will do to show digits , when button is clicked incriment value +1
then when button cycle goes to 1 then the display should show 0 again, this will help me understand what sequence number am on.

=======

look at this code i found
https://emalliab.wordpress.com/2015/07/24/icstation-4x4x4-led-cube-shield-for-arduino-software/

has snakes etc am trying to extract them and use on my project.
 

shteii01

Joined Feb 19, 2010
4,644
no lol.
it will be small hand gadget u just power it on and press button and cycle led modes.
i want to know how to do the police amber blinking.

left blink 3 seconds fast
then right blink 3 seconds fast
loop

==============================
button question
how do i add a digital display small one will do to show digits , when button is clicked incriment value +1
then when button cycle goes to 1 then the display should show 0 again, this will help me understand what sequence number am on.

=======

look at this code i found
https://emalliab.wordpress.com/2015/07/24/icstation-4x4x4-led-cube-shield-for-arduino-software/

has snakes etc am trying to extract them and use on my project.
I would suggest small lcd with serial communication because it will use 3 or 4 pins, since you just want to show a couple of numbers, you can get cheap 2x16 or 2x20 lcd: https://playground.arduino.cc/Learning/SerialLCD
2 lines, 16 characters on each line or 2 lines and 20 characters on each line.
Just make sure it uses 5 volts.
 

Reloadron

Joined Jan 15, 2015
7,890
left blink 3 seconds fast
then right blink 3 seconds fast
You may want to think about using a "for" loop. Also left blink 3 seconds fast and right blink 3 seconds fast fails to define time. You can't tell a program "fast" you need to define it. For example if I make redLed right and blueLed left you do the math for blinks per second that you want. For example:
Code:
int redLEDPin=9; //Declare redLEDPin an int, and set to pin 9
int blueLEDPin=10; //Declare blueLEDPin an int, and set to pin 10
int redOnTime=250; //Declare redOnTime an int, and set to 250 mseconds
int redOffTime=250; //Declare redOffTime an int, and set to 250
int blueOnTime=250; //Declare blueOnTime an int, and set to 250
int blueOffTime=250; //Declare blueOffTime an int, and set to 250
We setup two pins for red and blue and we also defined red and blue ON and Off times. At this point I would think about using a for loop as mentioned. Partial Example:
Code:
for (int j=1; j<=12; j=j+1) {     // Start our for loop
    digitalWrite(redLEDPin,HIGH); //Turn red LED on
    delay(redOnTime);             //Leave on for redOnTime
    digitalWrite(redLEDPin,LOW);  //Turn red LED off
    delay(redOffTime);            //Leave off for redOffTime
}
You know the On & Off times of the red led so if I do it 250 mS ON and 250 mS Off four times that is one second. Incidentally I have no clue what this would look like as I have not tried it.

Ron
 

Thread Starter

a Rob

Joined May 14, 2017
151
maybe tweaking will be needed thanks for the code i will try it and let u know how it went, cheers.
am looking for more of these codes that has different led effects:)
 

Reloadron

Joined Jan 15, 2015
7,890
maybe tweaking will be needed thanks for the code i will try it and let u know how it went, cheers.
am looking for more of these codes that has different led effects:)
The way to go about this is get creative. Creative means writing your own code starting with a blank sheet of paper. This is where you need to get a handle on how this all works. Cobbling pieces and parts of code together will yield junk.

Ron
 

Thread Starter

a Rob

Joined May 14, 2017
151
void pollice(){
int redLEDPin=2; //Declare redLEDPin an int, and set to pin 9
int blueLEDPin=6; //Declare blueLEDPin an int, and set to pin 10
int redOnTime=250; //Declare redOnTime an int, and set to 250 mseconds
int redOffTime=250; //Declare redOffTime an int, and set to 250
int blueOnTime=250; //Declare blueOnTime an int, and set to 250
int blueOffTime=250; //Declare blueOffTime an int, and set to 250

for (int j=1; j<=12; j=j+1) { // Start our for loop
digitalWrite(redLEDPin,HIGH); //Turn red LED on
digitalWrite(blueLEDPin,LOW); //Turn red LED on
delay(redOnTime); //Leave on for redOnTime
digitalWrite(redLEDPin,LOW); //Turn red LED off
digitalWrite(blueLEDPin,HIGH);
delay(redOffTime); //Leave off for redOffTime
}

}
 

Thread Starter

a Rob

Joined May 14, 2017
151
Code:
void pollice(){
  int redLEDPin=2; //Declare redLEDPin an int, and set to pin 9
int blueLEDPin=6; //Declare blueLEDPin an int, and set to pin 10
int redOnTime=250; //Declare redOnTime an int, and set to 250 mseconds
int redOffTime=250; //Declare redOffTime an int, and set to 250
int blueOnTime=250; //Declare blueOnTime an int, and set to 250
int blueOffTime=250; //Declare blueOffTime an int, and set to 250

for (int j=1; j<=12; j=j+1) {     // Start our for loop
    digitalWrite(redLEDPin,HIGH); //Turn red LED on
digitalWrite(blueLEDPin,LOW); //Turn red LED on
    delay(redOnTime);             //Leave on for redOnTime
    digitalWrite(redLEDPin,LOW);  //Turn red LED off
    digitalWrite(blueLEDPin,HIGH);
    delay(redOffTime);            //Leave off for redOffTime
}
 
}
this works ok
 

Thread Starter

a Rob

Joined May 14, 2017
151
Code:
void pollice(){
int redLEDPin=2; //Declare redLEDPin an int, and set to pin 9
int redLEDPin3=3;
int redLEDPin4=4;
int redLEDPin5=5;
//int redLEDPin=5;

int blueLEDPin6=6; //Declare blueLEDPin an int, and set to pin 10
int blueLEDPin7=7;
int blueLEDPin8=8;
int blueLEDPin9=9;
int redOnTime=250; //Declare redOnTime an int, and set to 250 mseconds
int redOffTime=250; //Declare redOffTime an int, and set to 250
int blueOnTime=250; //Declare blueOnTime an int, and set to 250
int blueOffTime=250; //Declare blueOffTime an int, and set to 250

for (int j=1; j<=9; j=j+1) {     // Start our for loop
    digitalWrite(redLEDPin,HIGH); //Turn red LED on
    digitalWrite(redLEDPin3,HIGH);
    digitalWrite(redLEDPin4,HIGH);
    digitalWrite(redLEDPin5,HIGH);
digitalWrite(blueLEDPin6,LOW); //Turn blue LED off
  digitalWrite(blueLEDPin7,LOW);
   digitalWrite(blueLEDPin8,LOW);
    digitalWrite(blueLEDPin9,LOW);
    delay(redOnTime);             //Leave on for redOnTime
    digitalWrite(redLEDPin,LOW);  //Turn red LED off
    digitalWrite(redLEDPin3,LOW);
    digitalWrite(redLEDPin4,LOW);
    digitalWrite(redLEDPin5,LOW);
    digitalWrite(blueLEDPin6,HIGH);
    digitalWrite(blueLEDPin7,HIGH);
    digitalWrite(blueLEDPin8,HIGH);
    digitalWrite(blueLEDPin9,HIGH);
    delay(redOffTime);            //Leave off for redOffTime
}
 
}
all 8 working now
 

Reloadron

Joined Jan 15, 2015
7,890
yup am working on it.

how would i go around making this effect
https://www.youtube.com/watch?time_continue=33&v=HIFDbUfOWhU
i think pickit 3 is used.

i think with picket 3 u can make some awesome led effects ? can they not be archived with arduino
Using an Arduino I can get the same results as with a PICKIT 3. Your link appeared to use some green LEDs using a "fade in" and "fade out" effect. A popular method for fading LEDs in and out is PWM (Pulse Width Modulation) and your Arduino has PWM pins and can run PWM just fine. You need to understand what PWM is and how it works.
Arduino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/outputpins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button.
PWM
The Fading example demonstrates the use of analog output (PWM) to fade an LED. It is available in the File->Sketchbook->Examples->Analog menu of the Arduino software.
You should have some PWM examples in your Examples file.

Ron
 

Thread Starter

a Rob

Joined May 14, 2017
151
this looks interested
reversing the sequence by click of a button.

https://github.com/Sam-Kearns/Arduino-LED-Chaser/blob/master/LED_Chaser.ino
look at this code
Code:
int numButtons = 3; // The number of buttons in the circuit
int buttonPin[3] = { 2, 4, 7 }; // An array of the pin numbers these buttons are connected to
boolean buttonState[3] = { false, false, false }; // An array indicating the last known state of each button
int numLEDs = 6; // The number of LEDs in the circuit
int ledPin[6] = { 3, 5, 6, 9, 10, 11 }; // An array of the pin numbers these LEDs are connected to

currently i have button connected to 5v pin on my project.
and 8 led using pin 2 to 9.


how can i set this up
 

Reloadron

Joined Jan 15, 2015
7,890
You either change your breadboard configuration or you modify the new code to fit your configuration.
Change Code for example:

Code:
int numLEDs = 6; // The number of LEDs in the circuit
int ledPin[6] = { 3, 5, 6, 9, 10, 11 }; // An array of the pin numbers these LEDs are connected to
Would become:
Code:
int numLEDs = 8; // [B]The number of LEDs in the circuit[/B]
int ledPin[6] = { 2, 3, 4, 5, 6, 7, 8, 9 }; //[B] An array of the pin numbers these LEDs are connected to[/B]
But as I mentioned previously when you start this copy and past game you open the door for problems because you need to change every single reference throughout the entire code. The above is a small example and I am not going to modify code for you. You need to start learning this stuff and doing it. Also I suggest if you plan on using buttons you start understanding 'pull up" and "pull down" as they pertain to the button Boolean expressions.

Ron
 

Thread Starter

a Rob

Joined May 14, 2017
151
Managing so far i made 19 modes by finding codes on github etc.
how much data can i store, how many modes on that atmega
 
Top