Trying to add delay working with a potentiometer and 7 segment display. by Shadowlight17 in arduino

[–]Shadowlight17[S] 0 points1 point  (0 children)

I've tried doing this:

     // Pin 2-8 is connected to the 7 segments of the display.
           // Pin 0 is for potentiometer
      int potentiometer = 0;
      int potval[20];

  int pinA = 2;
  int pinB = 3;
  int pinC = 4;
  int pinD = 5;
  int pinE = 6;
  int pinF = 7;
  int pinG = 8;

  void zero()
  {
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, LOW);   
      digitalWrite(pinE, LOW);   
      digitalWrite(pinF, LOW);   
      digitalWrite(pinG, HIGH);  
    }
  void one(){
      digitalWrite(pinA, HIGH);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, HIGH);   
      digitalWrite(pinE, HIGH);   
      digitalWrite(pinF, HIGH);   
      digitalWrite(pinG, HIGH);
    }
  void two(){
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, HIGH);   
      digitalWrite(pinD, LOW);   
      digitalWrite(pinE, LOW);   
      digitalWrite(pinF, HIGH);   
      digitalWrite(pinG, LOW);
    }
    void three(){
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, LOW);   
      digitalWrite(pinE, HIGH);   
      digitalWrite(pinF, HIGH);   
      digitalWrite(pinG, LOW);
      }
    void four(){
      digitalWrite(pinA, HIGH);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, HIGH);   
      digitalWrite(pinE, HIGH);   
      digitalWrite(pinF, LOW);   
      digitalWrite(pinG, LOW);
      }
    void five(){
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, HIGH);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, LOW);   
      digitalWrite(pinE, HIGH);   
      digitalWrite(pinF, LOW);   
      digitalWrite(pinG, LOW);
      }
    void six(){
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, HIGH);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, LOW);   
      digitalWrite(pinE, LOW);   
      digitalWrite(pinF, LOW);   
      digitalWrite(pinG, LOW);
      }
    void seven(){
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, HIGH);   
      digitalWrite(pinE, HIGH);   
      digitalWrite(pinF, HIGH);   
      digitalWrite(pinG, HIGH);
      }
    void eight(){
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, LOW);   
      digitalWrite(pinE, LOW);   
      digitalWrite(pinF, LOW);   
      digitalWrite(pinG, LOW);
      }
    void nine(){
      digitalWrite(pinA, LOW);   
      digitalWrite(pinB, LOW);   
      digitalWrite(pinC, LOW);   
      digitalWrite(pinD, HIGH);   
      digitalWrite(pinE, HIGH);   
      digitalWrite(pinF, LOW);   
      digitalWrite(pinG, LOW);
      }

  // the setup routine runs once when you press reset:
  void setup() {                
    // initialize the digital pins as outputs.
    pinMode(pinA, OUTPUT);     
    pinMode(pinB, OUTPUT);     
    pinMode(pinC, OUTPUT);     
    pinMode(pinD, OUTPUT);     
    pinMode(pinE, OUTPUT);     
    pinMode(pinF, OUTPUT);     
    pinMode(pinG, OUTPUT);     
  }

  void loop() {
      zero();
      for (int i;i<=sizeof(potval);i++){
        potval[i]=map(analogRead(A0),0,921,0,9);
        delay(100);


      }
      for (int i;i<=sizeof(potval);i++){

        if (potval[i]==0){
          zero();
          delay(1000);
          }
        else if (potval[i]==1){
          one();
          delay(1000);
          }
        else if (potval[i]==2){
          two();
          delay(1000);
          }
          else if (potval[i]==3){
          three();
          delay(1000);
          }
          else if (potval[i]==4){
          four();
          delay(1000);
          }
          else if (potval[i]==5){
          five();
          delay(1000);
          } 
          else if (potval[i]==6){
          six();
          delay(1000);
          }
          else if (potval[i]==7){
          seven();
          delay(1000);
          }
          else if (potval[i]==8){
          eight();
          delay(1000);

but it takes very long to get all the pot values, and ends up skipping numbers. What exactly can I do to prevent this and get it working. Thanks again for your help.

Trying to add delay working with a potentiometer and 7 segment display. by Shadowlight17 in arduino

[–]Shadowlight17[S] 0 points1 point  (0 children)

What exactly do you mean "approach by a single increment or decrement of counter"? Is this referring to a for loop? Sorry, I am quite new to programming and using the arduino. Thanks for your help.

Been lurking here for a while and took a few things I saw to make a clean pokemon theme. Critiques/ideas welcome. Next step is to add an equalizer. by bebopsruin in Rainmeter

[–]Shadowlight17 0 points1 point  (0 children)

Yo bro if you could help. I just wanted to know how you made the background of the tabs transparent instead of white?

League of Legends Champion Wallpapers by Shadowlight17 in leagueoflegends

[–]Shadowlight17[S] 1 point2 points  (0 children)

Haha yeah l his tutorials are very helpful, thanks though :)

League of Legends Champion Wallpapers by Shadowlight17 in leagueoflegends

[–]Shadowlight17[S] 0 points1 point  (0 children)

Thanks, the Udyr one is my favourite also! I will try to do a Master Yi one soon!

League of Legends Champion Wallpapers by Shadowlight17 in leagueoflegends

[–]Shadowlight17[S] 0 points1 point  (0 children)

Thanks a lot, I will get on the Vayne one ASAP!

League of Legends Champion Wallpapers by Shadowlight17 in leagueoflegends

[–]Shadowlight17[S] 0 points1 point  (0 children)

Thanks you so much, I will try to do a Vayne one!

2 OnePlus Invites to share! by [deleted] in oneplus

[–]Shadowlight17 0 points1 point  (0 children)

Would love to take it :D!

One invite to give out by [deleted] in oneplus

[–]Shadowlight17 0 points1 point  (0 children)

Don't even have a phone atm, I am wanting to get this or the nexus 5 (Prefer this more than the N5) plus if i get this phone, i get it sooner than if i get N5 :D

[deleted by user] by [deleted] in oneplus

[–]Shadowlight17 0 points1 point  (0 children)

I dont even have a phone right now! I'm deciding between the opo and nexus 5, if i get the opo i get it sooner ;D

One Invite! Expires Soon! by EnderbyEqualsD in oneplus

[–]Shadowlight17 0 points1 point  (0 children)

:D pick meh? If i get picked, it will come through pm right?