element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Hello,  I have an Arduino Uno and I am new to all this. What I am looking to do is control as many LED's as I can (14-20) in many ways. Such as: 2 Led's to flash back and fourth. 4 Led's to flash one after another. Some to flash randomly.  Some
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 4 replies
  • Subscribers 391 subscribers
  • Views 225 views
  • Users 0 members are here
Related

Hello,  I have an Arduino Uno and I am new to all this. What I am looking to do is control as many LED's as I can (14-20) in many ways. Such as: 2 Led's to flash back and fourth. 4 Led's to flash one after another. Some to flash randomly.  Some

Former Member
Former Member over 9 years ago
int led=2; int brightness=0; int fadeamount=5; voidsetup(){ //initialize digital pin as output pinMode(13,OUTPUT); pinMode(14,OUTPUT); pinMode(15,OUTPUT); pinMode(16,OUTPUT); pinMode(12,OUTPUT); pinMode(11,OUTPUT); pinMode(10,OUTPUT); pinMode(9,OUTPUT); pinMode(8,OUTPUT); pinMode(7,OUTPUT); pinMode(6,OUTPUT); pinMode(5,OUTPUT); pinMode(4,OUTPUT); pinMode(3,OUTPUT); pinMode(led,OUTPUT); voidloop(){   digitalWrite(13, HIGH);   delay(400);   digitalWrite(13, LOW);// turn the LED off by making the voltage LOW digitalWrite(12, HIGH);//here I am using Led's 13 and 12 to flash back and fourth   delay(400);     digitalWrite(12, LOW);// wait for a second delay(400);         digitalWrite(11, HIGH); //here I am using Led's 11,10 and 9,8 to flash one after another. delay(400);          digitalWrite(11, LOW);          digitalWrite(10, HIGH);               delay(500);                       digitalWrite(10, LOW);                  digitalWrite(9, HIGH);                  delay(500);                       digitalWrite(9, LOW);                  digitalWrite(8, HIGH); delay(500);                       digitalWrite(8, LOW);                   digitalWrite(7, HIGH); digitalWrite(6, HIGH); //here I am using Led's 6 and 7 to flash randomly                    delay(500);                  digitalWrite(7, LOW); digitalWrite(6, LOW);                       digitalWrite(14, HIGH); //here I am using Led's 14,15 and 16 to move right to left                       delay(500);                       digitalWrite(14, LOW);                         digitalWrite(15, HIGH);                       delay(500); digitalWrite(15, LOW);                       digitalWrite(16, HIGH);                       delay(300);                         digitalWrite(16, LOW);                       digitalWrite(15, HIGH);                           delay(500);                         digitalWrite(15, LOW);                           digitalWrite(14, HIGH);                         delay(500);                           digitalWrite(14, LOW);                         }                                     }
  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 9 years ago in reply to Former Member +1
    Most folks in this forum are happy to help you work things out, but you might have difficulty finding someone to completely rewrite the code to your specs, for free. I would suggest you learn more about…
Parents
  • Former Member
    Former Member over 9 years ago

    One thing I noticed, and you probably will to when you change the code, is the whole thing is going in sequence( one thing after another), each section needs to be independent of the others.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 9 years ago in reply to Former Member

    Most folks in this forum are happy to help you work things out, but you might have difficulty finding someone to completely rewrite the code to your specs, for free.

     

    I would suggest you learn more about the Arduino series, and their properties and limitations.  If you're not acquainted with them I would also suggest you learn about shift registers.  It would allow you to control multiple LED's from a single pin.  I don't know if you're thinking of a linear array, or some other configuration; but, LED strips with a controller for every three (SMD) LED's are relatively inexpensive.  There are digital and analog; with digital being easier to program.

     

    As per your follow-up message, you're are correct in saying these will sequence.  Using a Delay is OK if it's acceptable for the CPU to freeze after some command; but otherwise you should be using interrupts to allow the microcontroller to execute other actions.  There are several books (IMHO, best authors are: Massim Banzi, Tom Igoe, Simon Monk, Michael Margolis, and Jeremy Blum) that would be helpful.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 9 years ago in reply to Former Member

    thank you brian for your precious comment yes you are write that i need interrupt to run all the task at the same time instead of from one to the last....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • Former Member
    Former Member over 9 years ago in reply to Former Member

    thank you brian for your precious comment yes you are write that i need interrupt to run all the task at the same time instead of from one to the last....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube