Memory button or scroll through previous selections

Hello,

I created a system for my climbing wall that will light up the route A Brighter Moonboard - YouTube It works great except when I have a bunch of friends over and we are all changing the routes to light up our problem. I would like to figure out a way to either scroll back to a previous selection (IF statement) or setup a way that I can add buttons that I could assign as recall buttons on the fly. Maybe a user can hold down the button while entering the route number they want and when they hit that button it will pull that route back up. I would like to add about 5 "memory/recall" buttons. Any idea on how I can do this or any other suggestions to tackle this? The program is pretty simple with about 1500 IF statements that will light up when the user enters the number and hits #.

Thank you for any suggestions.

Chad

I don't really understand what you need help with.

I presume a "route" is a sequence of lights to be turned on-off in order
If you have (say) 5 different sequences each stored in an array it should be a simple matter to select the array using a button to cycle through the numbers 0 to 4.

However if there are 1500 steps in each sequence I'm not sure where you plan to save 5x1500 items in an Arduino.

Post your code!

...R

I have tried a couple times to paste the entire code and even shorting it but I keep getting an error that it exceeds 9000 characters. Basically what I have is an LCD, Keypad and a string of 198 addressable LED lights that will light up when a number is entered into the keypad. Each if statement is a different route (set of lights) that the climber follows up the wall, this works great. What I want to do is find a way that a climber can set a memory button to light up the route he is working on versus having to remember to enter 1432# each time it is their turn. There are 1,500 IF statements that look just like this except each is a different set of lights. Only the lines within that IF statement are performed when a route is selected...around 10 lines of code. The only other part of the code that is not show is the LCD and Keypad section which is pretty standard and the same type of IF statements. Thank you for your help and suggestions on how to tackle this.

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '5' && currentProblem[3] == '9'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(c18, 0xFF0000); //Green - Finish
strip.setPixelColor(d16, 0x00FF00); //Red
strip.setPixelColor(f14, 0x00FF00); //Red
strip.setPixelColor(d11, 0x00FF00); //Red
strip.setPixelColor(f8, 0x00FF00); //Red
strip.setPixelColor(c4, 0x0000FF); //Blue - Start
lcd.setCursor(0,3);
lcd.print("6B Try a Bump ");
strip.show();

}

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '6' && currentProblem[3] == '0'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(g18, 0xFF0000); //Green - Finish
strip.setPixelColor(d16, 0x00FF00); //Red
strip.setPixelColor(e14, 0x00FF00); //Red
strip.setPixelColor(c11, 0x00FF00); //Red
strip.setPixelColor(g9, 0x00FF00); //Red
strip.setPixelColor(f7, 0x00FF00); //Red
strip.setPixelColor(h4, 0x0000FF); //Blue - Start
lcd.setCursor(0,3);
lcd.print("6A Jazavac ");
strip.show();

}

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '6' && currentProblem[3] == '1'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(h18, 0xFF0000); //Green - Finish
strip.setPixelColor(i15, 0x00FF00); //Red
strip.setPixelColor(d13, 0x00FF00); //Red
strip.setPixelColor(f10, 0x00FF00); //Red
strip.setPixelColor(g6, 0x00FF00); //Red
strip.setPixelColor(j4, 0x0000FF); //Blue - Start
lcd.setCursor(0,3);
lcd.print("7B Otpor pokretu ");
strip.show();

}

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '6' && currentProblem[3] == '2'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(g16, 0x00FF00); //Red
strip.setPixelColor(h14, 0x00FF00); //Red
strip.setPixelColor(c11, 0x00FF00); //Red
strip.setPixelColor(d10, 0x00FF00); //Red
lcd.setCursor(0,3);
lcd.print("6C+ Jedaj ");
strip.show();

}

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '6' && currentProblem[3] == '3'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(f14, 0x00FF00); //Red
strip.setPixelColor(f11, 0x00FF00); //Red
strip.setPixelColor(h9, 0x00FF00); //Red
strip.setPixelColor(c7, 0x00FF00); //Red
lcd.setCursor(0,3);
lcd.print("6A Simplex ");
strip.show();

}

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '6' && currentProblem[3] == '4'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(f18, 0xFF0000); //Green - Finish
strip.setPixelColor(f15, 0x00FF00); //Red
strip.setPixelColor(h12, 0x00FF00); //Red
strip.setPixelColor(e10, 0x00FF00); //Red
strip.setPixelColor(h8, 0x00FF00); //Red
strip.setPixelColor(c4, 0x0000FF); //Blue - Start
lcd.setCursor(0,3);
lcd.print("6A L8 ");
strip.show();

}

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '6' && currentProblem[3] == '5'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(g18, 0xFF0000); //Green - Finish
strip.setPixelColor(h14, 0x00FF00); //Red
strip.setPixelColor(g9, 0x00FF00); //Red
strip.setPixelColor(g7, 0x00FF00); //Red
lcd.setCursor(0,3);
lcd.print("6A+ Speedy Stana ");
strip.show();

}

if (currentProblem[0] == '1' && currentProblem[1] == '5' && currentProblem[2] == '6' && currentProblem[3] == '9'){ 

colorWipe(strip.Color(0, 0, 0), 200);
strip.setPixelColor(d18, 0xFF0000); //Green - Finish
strip.setPixelColor(c16, 0x00FF00); //Red
strip.setPixelColor(e15, 0x00FF00); //Red
strip.setPixelColor(c13, 0x00FF00); //Red
strip.setPixelColor(e10, 0x00FF00); //Red
strip.setPixelColor(b9, 0x00FF00); //Red
strip.setPixelColor(e7, 0x00FF00); //Red
strip.setPixelColor(d4, 0x0000FF); //Blue - Start
strip.setPixelColor(g3, 0x0000FF); //Blue - Start
lcd.setCursor(0,3);
lcd.print("6A Girls accomodation 1 ");
strip.show();

}

You can add a program as an attachment if it is too long to include.

However I have a limited attention span for long programs. If you can produce a short program that illustrates your problem it would be much easier to help.

I can’t imagine what a program looks like that has 1500 IF statements. I don’t think my fingers could type that many :slight_smile:

I suspect those blocks for setting up the LEDs would be better put into separate functions so they don’t clutter the main part of the program.

I also suspect that, with a little planning, one or two lines of code would be sufficient to replace all of them.

…R

I added the IF statements to the previous comment so you can see what is going on. Do you know of a way to recall IF statements?

ChadJensen:
I added the IF statements to the previous comment so you can see what is going on. Do you know of a way to recall IF statements?

It is not good practice to change earlier posts because then the subsequent comments don't make sense.

In any case, I don't think the extra has added any clarity to your problem. I can only see 8 IF statements - not 1500 (thankfully).

There is no means to "recall IF statements" - except by using more IF statements.

I think this is a case where you have had an idea about how to implement your project which is far from the best way to implement it.

Can you describe what you want to do in English without any assumptions about how it might be programmed. Start from the beginning assuming I know nothing (which is the truth). It would also be a good idea to explain the problem based on small numbers (eg 8 LEDs, 3 choices etc). Worry about scaling up to full size later.

...R

Hello Robin,

I'm sorry that the IF statements didn't show up for you the first time, I didn't add them afterwards...must be that gremlin. :slight_smile:

Have you had a chance to watch the YouTube video that describes the project and shows it working? A Brighter Moonboard - YouTube

The system is working perfectly, I'm just trying to find a way to add a feature. After you watch the video you can find all the problems I reproduced at http://www.moonclimbing.com/moonboard/page.php?page=V:1

As you can see there are 1500 unique climbing routes with different hold patterns and that is why I had to use so many IF statements, one for each route. I tried case statements as well but still same concept of having a few lines of code for each route.

Thanks again for your suggestions

Chad

I am still at a loss to understand how you are managing the 1500 "routes". How do you store them in your Arduino?

I suspect if I knew that it would be easy to suggest a way of selecting between them.

Post the entire program - as an attachment if it is too big.

...R