element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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 Potentiometers on LED animation?
  • 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
  • State Not Answered
  • Replies 4 replies
  • Subscribers 402 subscribers
  • Views 429 views
  • Users 0 members are here
Related

Potentiometers on LED animation?

Former Member
Former Member over 14 years ago

Hi Guys, Just got my first Arduino yesterday and have jumped right into the deep end.. or atleast bouncing on the diving board over it maybe.

 

I bought the SparkFun Inventors Kit and have done up to CIRC-02. But I decided to modify it and see what I could do.

I changed the animation and added a Pot to the Circuit to adjust the delay in the program.

 

But my question is how do you program the Pot to adjust the animation instantly?

 

Right now once the animation starts it only re-adjusts the delay after it has completed the cycle.

So for example if the animation is really slow and has just started, you can adjust the Pot to speed it up but it doesn't change anything until it has completed the animation and goes to restart

 

Here is the void loop I have:

 

 

void oneAfterAnotherNoLoop(){
  sensorValue = analogRead(sensorPin);
  //the time (in milliseconds) to pause between LEDs
                      //make smaller for quicker switching and larger for slower
  digitalWrite(ledPins[0], HIGH);  //Turns on LED #0 (connected to pin 2 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[1], HIGH);  //Turns on LED #1 (connected to pin 3 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[2], HIGH);  //Turns on LED #2 (connected to pin 4 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[3], HIGH);  //Turns on LED #3 (connected to pin 5 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[4], HIGH);  //Turns on LED #4 (connected to pin 6 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[5], HIGH);  //Turns on LED #5 (connected to pin 7 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[6], HIGH);  //Turns on LED #6 (connected to pin 8 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[7], HIGH);  //Turns on LED #7 (connected to pin 9 )
  delay(sensorValue);                //waits delayTime milliseconds
//Turns Each LED Off
  digitalWrite(ledPins[0], LOW);  //Turns on LED #0 (connected to pin 2 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[1], LOW);  //Turns on LED #1 (connected to pin 3 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[2], LOW);  //Turns on LED #2 (connected to pin 4 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[3], LOW);  //Turns on LED #3 (connected to pin 5 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[4], LOW);  //Turns on LED #4 (connected to pin 6 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[5], LOW);  //Turns on LED #5 (connected to pin 7 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[6], LOW);  //Turns on LED #6 (connected to pin 8 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[7], LOW);  //Turns on LED #7 (connected to pin 9 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[7], HIGH);  //Turns on LED #0 (connected to pin 2 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[6], HIGH);  //Turns on LED #1 (connected to pin 3 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[5], HIGH);  //Turns on LED #2 (connected to pin 4 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[4], HIGH);  //Turns on LED #3 (connected to pin 5 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[3], HIGH);  //Turns on LED #4 (connected to pin 6 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[2], HIGH);  //Turns on LED #5 (connected to pin 7 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[1], HIGH);  //Turns on LED #6 (connected to pin 8 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[0], HIGH);  //Turns on LED #7 (connected to pin 9 )
  delay(sensorValue);                //waits delayTime milliseconds
//Turns Each LED Off
  digitalWrite(ledPins[7], LOW);  //Turns on LED #0 (connected to pin 2 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[6], LOW);  //Turns on LED #1 (connected to pin 3 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[5], LOW);  //Turns on LED #2 (connected to pin 4 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[4], LOW);  //Turns on LED #3 (connected to pin 5 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[3], LOW);  //Turns on LED #4 (connected to pin 6 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[2], LOW);  //Turns on LED #5 (connected to pin 7 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[1], LOW);  //Turns on LED #6 (connected to pin 8 )
  delay(sensorValue);                //waits delayTime milliseconds
  digitalWrite(ledPins[0], LOW);  //Turns on LED #7 (connected to pin 9 )
  delay(sensorValue);                //waits delayTime milliseconds
}

void oneAfterAnotherNoLoop(){

  sensorValue = analogRead(sensorPin);

 

 

 

  //the time (in milliseconds) to pause between LEDs

                      //make smaller for quicker switching and larger for slower

  digitalWrite(ledPins[0], HIGH);  //Turns on LED #0 (connected to pin 2 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[1], HIGH);  //Turns on LED #1 (connected to pin 3 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[2], HIGH);  //Turns on LED #2 (connected to pin 4 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[3], HIGH);  //Turns on LED #3 (connected to pin 5 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[4], HIGH);  //Turns on LED #4 (connected to pin 6 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[5], HIGH);  //Turns on LED #5 (connected to pin 7 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[6], HIGH);  //Turns on LED #6 (connected to pin 8 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[7], HIGH);  //Turns on LED #7 (connected to pin 9 )

  delay(sensorValue);                //waits delayTime milliseconds

 

//Turns Each LED Off

  digitalWrite(ledPins[0], LOW);  //Turns on LED #0 (connected to pin 2 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[1], LOW);  //Turns on LED #1 (connected to pin 3 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[2], LOW);  //Turns on LED #2 (connected to pin 4 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[3], LOW);  //Turns on LED #3 (connected to pin 5 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[4], LOW);  //Turns on LED #4 (connected to pin 6 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[5], LOW);  //Turns on LED #5 (connected to pin 7 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[6], LOW);  //Turns on LED #6 (connected to pin 8 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[7], LOW);  //Turns on LED #7 (connected to pin 9 )

  delay(sensorValue);                //waits delayTime milliseconds

 

//Turns Each LED ON in reverse order

  digitalWrite(ledPins[7], HIGH);  //Turns on LED #0 (connected to pin 2 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[6], HIGH);  //Turns on LED #1 (connected to pin 3 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[5], HIGH);  //Turns on LED #2 (connected to pin 4 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[4], HIGH);  //Turns on LED #3 (connected to pin 5 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[3], HIGH);  //Turns on LED #4 (connected to pin 6 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[2], HIGH);  //Turns on LED #5 (connected to pin 7 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[1], HIGH);  //Turns on LED #6 (connected to pin 8 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[0], HIGH);  //Turns on LED #7 (connected to pin 9 )

  delay(sensorValue);                //waits delayTime milliseconds

 

//Turns Each LED Off in reverse order

  digitalWrite(ledPins[7], LOW);  //Turns on LED #0 (connected to pin 2 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[6], LOW);  //Turns on LED #1 (connected to pin 3 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[5], LOW);  //Turns on LED #2 (connected to pin 4 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[4], LOW);  //Turns on LED #3 (connected to pin 5 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[3], LOW);  //Turns on LED #4 (connected to pin 6 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[2], LOW);  //Turns on LED #5 (connected to pin 7 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[1], LOW);  //Turns on LED #6 (connected to pin 8 )

  delay(sensorValue);                //waits delayTime milliseconds

  digitalWrite(ledPins[0], LOW);  //Turns on LED #7 (connected to pin 9 )

  delay(sensorValue);                //waits delayTime milliseconds

}

  • Sign in to reply
  • Cancel
Parents
  • DualFlop
    0 DualFlop over 14 years ago

    Hello Guy Renzetti,

     

    as far as I know the way for you to go is working with interrupts. At least this would be one way to communicate and switch functions on the fly.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • DualFlop
    0 DualFlop over 14 years ago

    Hello Guy Renzetti,

     

    as far as I know the way for you to go is working with interrupts. At least this would be one way to communicate and switch functions on the fly.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 14 years ago in reply to DualFlop

    Thanks, I guess I gotta keep going through the tutorials.

    I haven't gotten to interrupts yet.

     

    This is only day 3 for me now with learning programming.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
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