How to make 12 LED chaser without shift register

in #utopian-io7 years ago (edited)

Today i will going to share a basic arduino experiment on how to make 12 led chaser in arduino un board, This is a LED Chaser, with the simplest code. we can have different LED glowing arrangements, like Knight Rider is kinda famous, you can make it by simply putting the same loop but with descending outputs try it. so what you can learn on this post is, you can actually make your own christmas lights:) you can make this like a school invention, and you can learn a simple programming in arduino.

20180111_195147.jpg

Requirements

The requirements for this activity is just a basic parts in arduino, what we have are:

  • LEDs
  • 220 ohms resistors
  • Breadboard
  • jumper wires
  • arduino board
  • This is just a BASIC tutorial anf you gonna have to do is follow the circuit diagram i made, connect the led to the right pin on the arduino, so lets the invention, you can use my fritzing below;

    12led.png

    We don't need to use a shift register chip to 12 leds beacause the uno has 13 digital pins to make an output so lets start with the wiring, LED has 2 legs the long one is the common anode which means its a possitive and the short leg will be the cathode which is the GND or the negative leg. we need to use resistor to limit or we can say it regulates the amount of power that flows into the led, resistor is made from winding Nichrome or similar wire on an insulating form. This component, called a wirewound resistor and it can be able to handle higher currents. i started to put the led and the resistor into the breadboard.

    20180111_193929.jpg

    I use RED/YELLOW/GREEN leds and 12 220ohm resistance Arduino has two GND actually 3 GND pins 2 is along with power pins and other one is along with digital pins. Both of the GND pins are common, so you may connect the common cathode leg of the leds on the any GND pin. we have to put the short leg of the led to the horizzontal rail on the breadboard.

  • LED 1 to PIN 2 in arduino
  • LED 2 to PIN 3
  • LED 3 to PIN 4
  • LED 4 to PIN 5
  • LED 5 to PIN 6
  • LED 6 to PIN 7
  • LED 7 to PIN 8
  • LED 8 to PIN 9
  • LED 9 to PIN 10
  • LED 10 to PIN 11
  • LED 11 to PIN 12
  • LED 12 to PIN 13

  • This like connecting an object in grade school so its easy with a diagram to follow, and here it is the circuit is complete so go forward to the software.

    20180111_194420.jpg

    We are done building the circuit so lets start to set up and make a code for this. we are going to use the arduino ide, to set the sketch for this, if you dont have make sure to download the Arduino IDE for your specific operating system. I’ll leave a link to where you can download this software: https://www.arduino.cc/en/Main/Software

    seq1.png

    PIN 2 to 13 are the output pins to the leds, here the sketch for this chaser:
    leddddd.png

    This is very SHORT code if you want to copy the code, you can copy it below:

    void setup(){
      pinMode(2, OUTPUT);
      pinMode(3, OUTPUT);
      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);
      pinMode(13, OUTPUT); 
    }
    void loop(){
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(4, LOW);
      delay(100);
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(4, LOW);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(8, LOW);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(8, LOW);
      delay(100);
      digitalWrite(2, HIGH);
      delay(100);
      digitalWrite(2, LOW);
      delay(100);
      digitalWrite(2, HIGH);
      delay(100);
      digitalWrite(2, LOW);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(10, LOW);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(10, LOW);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(3, LOW);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(3, LOW);
      delay(100);
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
      delay(100);
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(7, LOW);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(7, LOW);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(12, LOW);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(12, LOW);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(5, LOW);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(5, LOW);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(11, LOW);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(11, LOW);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(6, LOW);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(6, LOW);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(9, LOW);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(9, LOW);
      delay(100);  
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(12, LOW);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(11, LOW);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(10, LOW);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(9, LOW);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(8, LOW);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(7, LOW);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(6, LOW);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(5, LOW);
      delay(100);
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(4, LOW);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(3, LOW);
      delay(100);
      digitalWrite(2, HIGH);
      delay(100);
      digitalWrite(2, LOW);
      delay(100);  
      digitalWrite(2, HIGH);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(13, HIGH);
      delay(100);  
      digitalWrite(2,LOW);
      delay(100);
      digitalWrite(3,LOW);
      delay(100);
      digitalWrite(4,LOW);
      delay(100);
      digitalWrite(5,LOW);
      delay(100);
      digitalWrite(6,LOW);
      delay(100);
      digitalWrite(7,LOW);
      delay(100);
      digitalWrite(8,LOW);
      delay(100);
      digitalWrite(9,LOW);
      delay(100);
      digitalWrite(10,LOW);
      delay(100);
      digitalWrite(11,LOW);
      delay(100);
      digitalWrite(12,LOW);
      delay(100);
      digitalWrite(13,LOW);
      delay(100);  
      digitalWrite(13,HIGH);
      delay(100);
      digitalWrite(2,HIGH);
      delay(100);
      digitalWrite(12,HIGH);
      delay(100);
      digitalWrite(3,HIGH);
      delay(100);
      digitalWrite(11,HIGH);
      delay(100);
      digitalWrite(4,HIGH);
      delay(100);
      digitalWrite(10,HIGH);
      delay(100);
      digitalWrite(5,HIGH);
      delay(100);
      digitalWrite(9,HIGH);
      delay(100);
      digitalWrite(6,HIGH);
      delay(100);
      digitalWrite(8,HIGH);
      delay(100);
      digitalWrite(7,HIGH);
      delay(100);  
      digitalWrite(2, HIGH);
      delay(100);
      digitalWrite(2, LOW);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(3, LOW);
      delay(100);
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(4, LOW);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(5, LOW);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(6, LOW);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(7, LOW);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(8, LOW);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(9, LOW);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(10, LOW);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(11, LOW);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(12, LOW);
      delay(100);
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
      delay(100);  
      digitalWrite(2, HIGH);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(13, HIGH);
      delay(100);  
      digitalWrite(13,LOW);
      delay(100);
      digitalWrite(12,LOW);
      delay(100);
      digitalWrite(11,LOW);
      delay(100);
      digitalWrite(10,LOW);
      delay(100);
      digitalWrite(9,LOW);
      delay(100);
      digitalWrite(8,LOW);
      delay(100);
      digitalWrite(7,LOW);
      delay(100);
      digitalWrite(6,LOW);
      delay(100);
      digitalWrite(5,LOW);
      delay(100);
      digitalWrite(4,LOW);
      delay(100);
      digitalWrite(3,LOW);
      delay(100);
      digitalWrite(2,LOW);
      delay(100);  
      digitalWrite(2, HIGH);
      delay(100);
      digitalWrite(2, LOW);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(3, LOW);
      delay(100);
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(4, LOW);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(5, LOW);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(6, LOW);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(7, LOW);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(8, LOW);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(9, LOW);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(10, LOW);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(11, LOW);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(12, LOW);
      delay(100);
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(13, LOW);
      delay(100);  
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);
      digitalWrite(10, HIGH);
      delay(100);
      digitalWrite(9, HIGH);
      delay(100);
      digitalWrite(8, HIGH);
      delay(100);
      digitalWrite(7, HIGH);
      delay(100);
      digitalWrite(6, HIGH);
      delay(100);
      digitalWrite(5, HIGH);
      delay(100);
      digitalWrite(4, HIGH);
      delay(100);
      digitalWrite(3, HIGH);
      delay(100);
      digitalWrite(2, HIGH);
      delay(100);  
      digitalWrite(13,LOW);
      delay(100);
      digitalWrite(2,LOW);
      delay(100);
      digitalWrite(12,LOW);
      delay(100);
      digitalWrite(3,LOW);
      delay(100);
      digitalWrite(11,LOW);
      delay(100);
      digitalWrite(4,LOW);
      delay(100);
      digitalWrite(10,LOW);
      delay(100);
      digitalWrite(5,LOW);
      delay(100);
      digitalWrite(9,LOW);
      delay(100);
      digitalWrite(6,LOW);
      delay(100);
      digitalWrite(8,LOW);
      delay(100);
      digitalWrite(7,LOW);
      delay(100);  
      digitalWrite(13, HIGH);
      delay(100);
      digitalWrite(12, HIGH);
      delay(100);
      digitalWrite(11, HIGH);
      delay(100);  
      digitalWrite(11,LOW);
      delay(100);
      digitalWrite(12,LOW);
      delay(100);
      digitalWrite(13,LOW);
      delay(100);
    }

    You can change the delay time of the led on the sketch, so lets upload it to the board and lets see how its works,

    20180111_195546.gif

    You see it, its a christmas lights with a code, i hope you enjoy this actitvity if wan to learn how arduino works, and how to make a sketch, then maybe this blog might help you, i was inspired by engmousaalkaabi for this wonderful stuff. so thats it, if you want to know and see my future activity follow me! thank you.

    You can also check my previous posts:

    Control LED using Push Buttons/ Visual programming using XOD
    Control Servo motor using Joystick
    Stepper motor + Driver Uln2003 in arduino
    Control Servo motor using potentiometer - arduino

    20180105_182452[1].jpg



    Posted on Utopian.io - Rewarding Open Source Contributors

    Sort:  

    Thank you for the contribution. It has been approved.

    You can contact us on Discord.
    [utopian-moderator]

    Hey @pakganern I am @utopian-io. I have just upvoted you!

    Achievements

    • This is your first accepted contribution here in Utopian. Welcome!

    Suggestions

    • Contribute more often to get higher and higher rewards. I wish to see you often!
    • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!

    Get Noticed!

    • Did you know project owners can manually vote with their own voting power or by voting power delegated to their projects? Ask the project owner to review your contributions!

    Community-Driven Witness!

    I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

    mooncryption-utopian-witness-gif

    Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

    Oh my god, my wife asked me to buy a LED driver for the country house, but I don't want to do it myself. Can anyone advise where to buy it and how much it should cost?

    Lmao, I understand I have no desire to assemble all the necessary equipment myself either. The prices of LED drivers depend on the power you need. In your case, it depends on the number and length of the lights. I have an ecopac led driver at home, it cost about £50. It's worth the money because it protects against overheating and short circuits, for my anxiety about the house is essential. I bought it for myself and for 3 years I have peace of mind that everything should be ok with my appliances. I think it's great. I'm thinking of buying a LED driver for the backyard now. We have a lot of lights hanging there too.

    Coin Marketplace

    STEEM 0.18
    TRX 0.15
    JST 0.032
    BTC 60972.25
    ETH 2632.93
    USDT 1.00
    SBD 2.57