Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today! (You will need to be logged into the store)
Official Members also get to use the forum ad-free - so kit up and join us!


Electronics : Random (pattern) Blinking LEDs

  • 0 Replies
  • 4637 Views

Havelock


    *
  • 11989
  • I probably have a link for that.
  • Awards Celebration Anaheim 2022 6 or more Education Points in a single year. Award for 10 official invasions. Order of the Ori'Ramikad Celebration Orlando 2017
: Random (pattern) Blinking LEDs
« on: May 22, 2018, 12:28 PM »
Random (pattern) Blinking LEDs
Lead Author: Bar'uun Strieg
Edited by: MMCC Education Team


The goal of this guide is to have several LEDs of different colors that blink in a random pattern.  This tutorial will primarily deal with how to setup the circuit for the blinking LEDs.  It will give suggestions as to how it could be incorporated into your bucket, your gauntlet, or some other prop.  With this project, you could have up to 14 LEDs that all blink randomly (more if you were to connect multiple LEDs in series).  We will only be using 3 LEDs in this design.



Project Difficulty:  Easy

Required Items for project:

  • Computer with Arduino IDE installed
  • USB Cable to connect computer to the Arduino
  • Breadboard for the circuit setup
  • Jumper wires
  • Red LED and a 180 Ohm resistor
  • Blue LED and a 100 Ohm resistor
  • Green LED and a 100 Ohm resistor
  • Arduino Uno

Start by familiarizing yourself with the breadboard.  The two outermost rows of holes on each side are designed to carry power.  Each side has a red lined column of holes (positive voltage) and a black(sometimes blue) lined column that is for negative or ground connections.  These columns are joined together underneath the breadboard.  Between these columns are rows of holes that are also joined together underneath the breadboard.  Each of the rows are split down the middle to allow for multiple connection points.  Numbers and letters corresponding to the columns and rows are for reference.  The image below should make this clearer.


Start by taking the Green LED and inserting the long leg (anode) in row 18 of column a.  Insert the shorter leg (cathode) in row 19 of column b.  Take the red LED and insert the anode in row 22 of column b and insert the cathode in row 23 of column b.  Using the blue LED, insert the anode in row 26 of column b, and the cathode in row 27 of column b.



Now, take one of the 100 Ohm resistors and insert one leg in column a, row 19 (same row as the cathode for the green LED).  Insert the other leg of the resistor in the outer column marked with a “-“, the negative column.  Take the 180 Ohm resistor and insert one leg in row 23, column a.  Insert the other leg in the outer negative column.  Take the other 100 Ohm resistor and insert one leg in row 27 of column a, and insert the other leg into the outer negative column.



Place the Arduino UNO beside the breadboard holding the LEDs and resistors.
Take a jumper wire and insert one end in row 18, column e.  Insert the other end of the jumper wire in the receptacle labeled 8 on the Arduino.  The sketch we will use for this circuit will use Pin 8 of the Arduino to control the green LED.
Take a jumper wire and insert one end in row 22, column e.  Insert the other end of the jumper wire in the receptacle labeled 9 on the Arduino.  The sketch we will use for this circuit will use Pin 9 of the Arduino to control the red LED.
Take a jumper wire and insert one end in row 26, column e.  Insert the other end of the jumper wire in the receptacle labeled 10 on the Arduino.  The sketch we will use for this circuit will use Pin 10 of the Arduino to control the blue LED.
Take a jumper wire and insert one end anywhere along the negative column where one leg of each resistor are already inserted.  Insert the other end of the jumper wire in the receptacle labeled GND on the Arduino.



The circuit is complete.  When the Arduino sends power to each LED via the control pin it is connected to, the power will be returned via the common ground (GND) connection of the Arduino…..and the LEDs will blink.

Open the Arduino IDE on your computer.  Then open a New Sketch.  Delete any lines that appear by default.  Copy and paste the following code into the blank Sketch window.  Don’t worry if this all looks like a foreign language.  You will come to an understanding of it if you pursue doing Arduino code later on.  This sketch was taken from this website.  It has a good explanation of how the code works, though without a coding background it may still seem like a foreign language.
Code: [Select]
int leds[6] = {8,9,10,11,12,13};

void setup(){
  for (int jj; jj<sizeof(leds)/sizeof(int);jj++){
    pinMode(leds[jj],OUTPUT);
    delay(10);
  }
}

void loop(){
  digitalWrite(leds[random(0,sizeof(leds)/sizeof(int))],HIGH);
  delay(random(20,200));
  digitalWrite(leds[random(0,sizeof(leds)/sizeof(int))],LOW);
}

Once you have pasted the code in the Sketch window.  Select the SAVE option and give the sketch an appropriate name.  After you save the Sketch, select the Checkmark icon to compile and verify the code contained in the sketch.

Connect the Arduino Uno to your computer via a USB cable.

From the “Tools” menu, ensure that for the “Board” option, Arduino Genuino/Uno is selected.
Also from the “Tools” menu, ensure that the “Port” option is selected for whatever USB port the Arduino is connected.
Once you have verified these items, choose the Arrow icon from the sketch window to upload the sketch to the Arduino.  You should observe the LEDs on the actual Arduino board flash as the sketch is written to the board.  Once the sketch is written to the board, you should see the LED circuit you created comes to life with blinking LEDs similar to the video below.


This project can be modified for inclusion in a helmet, prop, or whatever.  The basics remain the same, though you would need to select a smaller Arduino based controller such as an Adafruit Metro Mini or similar clone.  These boards have the same number of control pins and could easily handle this project, while doing it in a much smaller package. 

The other difference would be that you would be soldering the wires and resistors together and then soldering them to the pins of the Arduino board you chose, as well as attaching a battery to power the project. 

In summary

This should introduce you to working with LEDs, arduino controllers, and will hopefully inspire you to create your own projects.  Projects like this are really only limited by the amount of space you have to work with (which can usually be worked around), and your imagination.

--MMCC Education Team--

« Last Edit: Dec 16, 2019, 07:01 AM by Hik'aari » Logged
"Sometimes it's better to light a flamethrower than curse the darkness."  - Terry Pratchett
Have you explored all that the Royal War College of Mandalore has to offer?
 


Don't like ads? Help support the Mercs by becoming a Supporter or Auxiliary Member today! (You will need to be logged into the store)
Official Members also get to use the forum ad-free - so kit up and join us!



Powered by EzPortal
SMF spam blocked by CleanTalk