Effect switcher and relays - EEPROM question

There you go again!

I have only a few increments of time here, so:

One:

Now that doBank and doDown have legitimate actions given the realMode, the <whatevs> here

  //  bankUp();
  //  bankDown();

  if (realMode == READ) {
    if (doBank) {
// whatevs
    }
    if (doDown) {
// whatevs
    }
  }
  if (realMode == WRITE) {
    if (doBank) {
// whatevs
    }
    if (doDown) {
    }
// whatevs
  }

should really be moved into place in the one switch/case so the logic is entirely

what mode are we in + what button got pressed = some action to take maybe changing the mode as part of that action.

Two:

Just curious why the pended mechanism was commented out here:

    case SAVED :
      //    lcdDwellTime = now;    // transient message. time or user activity moves to the pended screen

It means that screen whistles by, no one will see it.

Three:

The There you go again! was for kludging the keyboard column with a switch. I won't share her reaction. At least it isn't a relay. :expressionless:

Keep the keyboard doing its job - telling you which key got pressed. Use logic to adjust it if you are in some kind of alternate mode, like if a real keyboard you had the control key pressed, perhaps like this:

// define a shift button or switch input up top
const byte shiftKey = 2;

// and
//  in setup
  pinMode(shiftKey, INPUT_PULLUP);  // wire middle and one end between pin and GND


// then here account for the shift or alternate function

  char key = keypad.getKey();
  if (!key)
    key = NOKEY;
  else {
    key -= 'a';
    if (digitalRead(2) == HIGH)
      key += cols;  // bump 0..N - 1 to N..2N -1, here 0..7 becomes 8..15
  }

As I said, a well-written sketch can tolerate a certain amount of "hey, if I just do this here, that over there will work like I want it to". So defer, delay and avoid spending that capital until absolutely necessary. Here it is entirely avoidable, and doing isn't even a hack - shiftig the keypad returned number at the only point where you read it is 100 percent legit.

Four:

There are a few paintLCD() calls and I think the ACK blinker launch call that are scattered. They can (we did it) and should be moved into the loop() realMode switch/case. Not sure what name to give that, let's just call it keeping things that do different stuff more all like in one place, and let the little helper functions just do what they need to, viz:

      if (key != NOKEY) {
        memory(currentBank * bankSize + numberOfPedals * key, key);  // theAddr, theLED

        paintLCD(SAVED, theLED);  // let her know (transient screen)
        blinkAnAck(theLED);       // kick start the ACK blinker

        realMode = READ;          // (pended screen)
        paintLCD(RUN, 0, 101);
      }

Last:

Start getting aggressive about removing stuff that was found to be in error, or is obsolete. Leave things if you need to remember how they were, but this kinda thing

      if (doSave) {
        //      dumbBitchLCD();
        paintLCD(DUMBBITCH);

is where I mean lose it, it is of no further interest. If only so that searching in N hundred lines of code you won't be tripping over things like that - you may have seen in some commented stuff I mangle a word so it is readable but not findable, and also this was why I made okDelay(), so a case-sensitive search for delay() will only find actual uses of a real, not-OK delay. Of which there should, in the end be but one... found in okDelay().

And you must be the judge, when you introduce delay() anywhere, that it is indeed OK.

BTW - outta time, I'll look L8R, but have you changed away the hardware so there are no longer any single-coil latching relays?

a7

haha - okay okay, but hear me out...

LOL. It was never my intent to leave a switch there - it was merely to get the function going so I could reverse the logic into non-slide switches. Now that I know what's possible, I won't be going backwards... FEAR NOT!

I tried this originally, but it wasn't working with the buttons - I'll take a look in the morning or afternoon to see if maybe I just had the logic in the wrong place. I was trying to create functions for the buttons outside the loop, which worked for the bank buttons on their own, but not in the switch case, so that could've been my trip-up AND why the logic is where the bank buttons were in the first place.

This is me experimenting with the timings. Remember when I was having that blank screen issue? I think it was because I had spent too much time in program mode, so when I got to save mode the screen just went blank - the lcdDwellTime was the culprit. Once I turned them all from 5 seconds to 2.5 seconds, it got worse, so I turned this off temporarily while I figured out my screens and timing.

I would probably never have found this solution on my own, LOL - so thank you again. Will have a play in the morning, but this is pretty much where I wanted to take this...

some oddities (from me, taking full responsibility) happened while I was trying to get effect banks to work. I'll take a look through and be sure things are where they need to be for sure.

1000% - this probably would be gone if it weren't for me being dumb and making edits on an older version on a different computer (lcd.clear came back to haunt me, too). I've learned a valuable lesson about saving/refreshing, hehe.

The actual switch relays are still single coil latched DPDT relays (Panasonic TQ2-L-5V to be exact). I have nearly 2 dozen of them, so they are getting used. The blue and red LEDs represent the optocouplers in the wokwi - each coil has 2 pc817 optos with 2 S8050s in a not-gate setup to fire the coils to latch/switch. I tested this setup on the breadboard and it works well.

Anything involving the Arduino program (e.g. switching banks, presets, read, write, save, etc.) is relay-free, toggle-free, slider-free, etc., and will stay that way, hehe...

And it's functional - needs tweaking, but your solve worked:

https://wokwi.com/projects/388081117082022913

NO TOGGLES OR SLIDERS! hehe. :wink:

I haven't moved the respective bank button code into their cases yet, but I was able to use a version of your code for the effectBank, and that works well now. Just had to add an if/then to always set it back to "1" in save mode so it only uses presets 1 through 8. (if it's in effectbank 2 before save, then it saves to presets 9 through 16, which have no buttons).

Turns out this was not the culprit to the blank screen, as my simulator is blanking out at Save again... I need to get a better handle on the LCDs, but will test in the morning and tweak as needed - I have an older version saved that has the original LCD setup after I incorporated your solve there. That'll help me get back to base version and tweak as needed.

Unreal helpful - this is almost done, and that's a good feeling!

I will review your entire message. But this one line saves me a few hundred words…

I'll assume this is a frozen checkpoint that if eveything else disappeared would be no tragedy, and that anything tweaked, hacked, adjusted, broken or otherwise different will not be this version, but your own new work-in-progress.

a7

In the brief time I've had this morning, I moved the bank button functions into their respective switch cases - seems to work, but finding other quirks now... namely, all of the effect LEDs are now on when I hit a preset that doesn't have anything saved in it. They turn off when I hit a preset with saved effects, but this is a new behavior for sure.

I also had a couple times when I hit the program button and it just went right back to read - I'm wondering if that's a problem with my computer, though (recall that it's always around 60% on this computer and the buttons aren't happy about that).

I also removed the pended lcd "comment-out" from the save screen. I need to do further testing with the screens, but figured I'd at least get it back to something closer to before. Working, but needs some TLC. Will get to that this afternoon. Your beach is our Indiana Dunes, so coding will have to wait... :slight_smile:

More the follow, as always...

You did not say you have parked a frozen version anywhere. I cannot work on a moving target, I don't want to work on something with things temporary modified as you chase flaws that I think are ones you are introducing as you go.

I have not seen that you make any use of the serial monitor, but I haven't looked either, but things like you describe are breakages that must certainly be due to very recent activities.

Take small steps away from the solid frozen solid version as you work on progress. Develop a known test sequence you can rapidly apply to quickly confirm the thing still flies.

This can be difficult when making major changes, but as an example, when we did stand up neopixels to replace every real LED, we left those LEDs in there to the last minute, and during the process every test was confirmed by seeing the neopixels do exactly what the LEDs (still) did.

Or not. Maybe the neopixels didn't match the LEDs, which were correct. Maybe both were the same and both were wrong. Clues they were to swing why the additions were flawed, or why they broke everything.

I mentioned the serial monitor; I might have had 90 percent of this fully functional before I even put an LCD on in there, simulated or no.

I think an early version of this ran off characters fed from the serial monitor input window, or I am thinking of a different project, but here too I might have been way down the road before I attached the keypad and maybe even any buttons.

Keeping all the functional elements at a distance to each other through software is one key to maintaining sanity, and is useful when things break as you can step back and remove entire functions, blocks of software and the hardware it controls to isolate difficulties the otherwise might baffle.

Which is why I was able to think that you were c having a red herring with the lenses screen thing…

I appreciate it's late in this game for all this advice, but I am betting this won't be your last project, so.

I'm working on the Nth version of a toy, large enough N here and inside it is a block we call the engine, which was developed in C and runs using a command line interface. Nothing goes in or out of the engine except characters… and that code has not changed at all since I got it working correctly. It is about 70 percent of the code of any versions with keypads, LEDs, OLED displays, beepers, touchpads or neopixels and is never ever why something new does not work.

You should hear what happens when someone suggests adding a feature that would require modifying the engine… or lobbies for as dong a layer to the engine to change it. That kinda thing seems to have worked out for the evolution of the human brain, but in product development not so much.

a7

OK, just tooling around at a relatively high altitude in

And I am confused by the "shift" logic. Is selecting the second effectBank exactly and only when you want to shift to the next range of returned numbers? You can just say "yes".

  char key = keypad.getKey();
  if (!key) {
    key = NOKEY;
  } else {
    key -= 'a';
    if (effectBank == 2)
      key += cols;
  }

I didn't but this was spotted

      case SAVE:
      if (effectBank = 2) {    //// Bzzzt!
        effectBank--;
      }

that is an error, surely you meant to compare for equality, not do an assignment in the if statement test.

This is an easy error to make, and a difficult one to find.

In the IDE, go to the preferences and turn up all warnings and verbosity. Then verify your sketch, and heed the red ink, which will say something like "is that what you really meant" for that line of code and other similar perfectly legal but maybe not what you meant code.

A reasonable goal is to have no red ink spill from your own code. Unfortunately libraries are a source of warnings as they can be written by ppl who know damn well what they are doing and don't pay any heed to no stinkin' warnings.

We'll play with this version and try to get a grip on the additions.


I see once again something I proposed and you tried, failed to get working but used the idea of is now working the way I thought it should, in this case making one realMode switch/case do all the work.

Also, you have to start cleaning and keeping things clean. If the code changes, you should look at any comments and keep them accurate and meaningful. This is why many ppl don't use comments much, and why I, for example, routinely ignore them when reading forum code posted by not me. They can be gratuitous, out of date, misleading or just plain wrong too more often than useful.

Here

const byte cols = 8;

char keys[rows][cols] = {
  { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' },
  { 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' },
};

is another kinda thing - as far as I can tell from this brief glance, you do not have a two column keypad, and are no longer hacking the column lines to make keypad think there are...

a7

totally fair - I've renamed that WOKWI linked above to be the WIP while I tweak and test in another project - I definitely learn by doing, so this is my bad. I'll try and explain the rest...

Yes, but...

I need everything to only save in presets 1 through 8. If I don't set the effectBank back to 1, SAVE mode goes into presets 9 through 16 - there are no buttons for those, so that's no good.

Correct again: this was an unnecessary edit.

I have not changed the WIP wokwi since your last 2 messages, and will leave that as is here so that your thoughts/comments/solves work and make sense against where everything currently is: https://wokwi.com/projects/388081117082022913

IF YOU ARE CURIOUS, my new playground where I've applied your most recent comments and learnings is here: https://wokwi.com/projects/388207146432303105 - I've noted everywhere that I've made modifications with a "// WHOA WHOA WHOA " note. There aren't changes like there were before, it's mostly just cleaning up and applying your recent notes, but I did want to keep it separate from the WIP. Let me know if I should be doing this differently.

As always, my gratitude runs deep - and my apologies for jumping the gun a bit... definitely ready to get this thing into my switch! hehe...

THX, I will proceed fearlessly. :expressionless:

Meanwhile, I am not sure you understood my remarks on

      if (effectBank = 2) {    //// Bzzzt!
        effectBank--;
      }

as it happens, you were lucky.

this if statement

  • assigns the value 2 to effectBank, and because 2 is true, always executes the body which
  • decrements effectBnak making it 1

and as such is a confusing and long winded way of saying

       effectBank = 1;

I believe you intended to check if effectBank is equal to 2, and if so decrement it:

      if (effectBank == 2) {
        effectBank--;
      }

The fact that effectBank only takes on two values means all use of it would need close examination should the number of effect banks be changed.

It isn't too important I guess unless you have anything like that in mind. It would be clearer to have not a number of effect banks (two) and the up/down logic, and making it look to casual reader like it could be three or whatever, but instead a Boolean variable like shifted or not, forever and obvsly either one effect bank or the other.

As a personal project you will of course be personally responsible for keeping details like this familiar. Speaking as someone who forgets what he had for breakfast before lunch time comes, I'm alla time looking at code I wrote saying what the hell was this guy thinking here… I've got lotsa things I am very happy work well enough I don't have to figure out just how, anymore.

a7

I have a few things for right away.

First, I think if there are two and only two and forever only two effect banks that the buttons up and down should not toggle the fx bank, rather that one of the up and down buttons should select bank A and the other should select bank B.

Or the LEFT bank and RIGHT bank, ah Paris in the the Spring!

Next, you have a real defect in the code.

Examine all use of the photoPin array and remove any reference to elements beyond the two that exist. Some loops include the array and write nonsense to nonsense. This can cause anything to happen anywhere, and makes it a very difficult flaw to find.

Which I looked for because the serial screen said "paintƻng", not "painting", and found by combing through the... wait for it... compiler warnings.

There are a crap-ton of warnings, someone here will go through them and help you know which are serious and which can be ignored as in we know what we are doing or come from library code.

Add const here (line 27 or so) and be playing by the rules

const char *screenTag[] = {
  "DUMBBITCH", "READPRESET", "WRITEOUT", "RUN", "SAVED", "PROGRAMMODE", "SAVEMODE", "SPLASH", "NO_SCREEN"
};

a7

I agree - it wasn't my favorite interface and this solution works better.

THANK YOU! I couldn't figure out why my preset button pins were having issues or why the monitor was throwing odd characters, as you mentioned, and this was the culprit. I also finally got the setting right in the Arduino settings to show the full compiler warnings, which I've been working through.

Done.

current "personal" wokwi: https://wokwi.com/projects/388207146432303105 - all shifts marked with "// WHOA WHOA WHOA"

(The WIP wokwi is here, untouched until I get the go-ahead, hehe)

Working through them now - there are only 4 left, which are:

line 112: warning: unused parameter 'theLED' [-Wunused-parameter]
 void memory(int theAddr, int **theLED**) {

This is the result of moving "theLED" into a function that handles the neopixels (getEffectLED). It was the only solution that allowed the neopixels to work and program properly. I'll have to sleuth on this for a bit, but feeling it may be a quirk of how it references and saves from the neos.

line 540: In function 'int paintLCD(byte)':
warning: no return statement in function returning non-void [-Wreturn-type]
}
 
line 543: In function 'int paintLCD(byte, byte)':
warning: no return statement in function returning non-void [-Wreturn-type]
}

line 559: In function 'int paintLCD(byte, byte, byte)':
warning: return-statement with no value, in function returning 'int' [-fpermissive]
     return;

I'll admit that I'm stumped on these. I'll have to see if they ultimately matter or can be ignored...

If it is unused, it's unused. It can be removed as a parameter in the definition of the function, and then must be removed as an argument wherever the function is called.

Or the warning can be ignored and the code unchanged. The reasons against this are mainly that it confuses the reader, who must go to some trouble only to find that it is extra ink. One day you yourself will be the reader...


Here

no return statement in function returning non-void

is my bad. I anticipated the need to return a value from any functions the compiler complains about; there was no need, and no callers to those functions expected anything to be returned, so in all those cases the compiler will shut up if you simply tell the truth by changing the return type to void which means nothing.

void paintLCD(byte screenName, byte argument, byte extra)
{
  Serial.print("          blah blah  Bob Loblaw

//... 
}  

You've been seeing void return types for functions since setup() and loop(). Noobs often call functions voids because, which always amuses.

I can't now but I'll look - I don't think any of the sketch uses functions that do return a value.

I should have had my place keeper functions returning int just return zero, but then the warnings would be more numerous and read something like "return value ignored in call to paintLCD" so you really have to just play by all the rulz all the time, which is best as it can def eliminate true errors, or things that might one day become problematic.

a7

Did a bit more research on the compiler errors, and the ones that are left are harmless so far as I can tell. I added comments in the code to note them and that they aren't fatal.

Everything is working really nicely, so I'm happy. While I understand some tweaks may still come my way, I've created what will hopefully be the final Wokwi for this project: https://wokwi.com/projects/388305663850086401 (older versions here: WIP and Personal)

I went through and scrubbed the comments and old code, as well as noted what each section does to the best of my abilities.

I also added a rainbow to the neopixels at start up because... why not? lol. 3.5 seconds of fun! (there's a college nickname in there somewhere I'm sure).

While I'm sure there are better ways to code some things (bank buttons and associated functions, notably), they are working and it feels pretty solid. The ONLY thing that's a little wonky is when moving from effect bank 1 to 2 and vice-versa, it resets the display to pedal/effect 1 even though it's not selected. I can live with this as the LEDs are lit for the actual choices, but it's probably something I'll think about over the coming week while I'm designing the PCBs for the relays.

If there are 16 effects, and I have 16 spots on a single LCD line, I wonder if I can use the entire second line and somehow have a character show up for the respective chosen effect. Something like:

ā€”ā€”ā€”ā—Šā€”ā—Šā€”ā€”ā—Šā€”ā€”ā€”ā—Šā€”ā—Šā€”

(dashes would be empty, diamonds mean you have an effect selected). So far, I've only used the LCD to print entire lines, not have such interactivity. I'd need to see what the LCD can handle, but that's the only thing from a user stance that's on my mind.

Is there anything else you think might be in order before I call "close enough"? lol...

As always, thank you beyond... way helpful and I'm in a great place compared to 2 weeks ago - REALLY appreciate the help!

OK, looking to advice you on fixing this:

At this late stage, it would be acceptable to do the kind of thing that would be offensive and weaken the integrity of the sketch. But it won't be necessary, there is sufficient flexibility to handle this however you'd like.

I've not commented but always thought it was stupid odd to publish the number of the last effect button pressed, whether it was turning on or off the inclusion of that effect in the set. The LED on the slot is sufficient.

But I agree it is a flaw to put 1 there when it may or may not be selected and may or may not have been the last effect slot to be toggled.

Without thinking about how to code it, sit quietly and decide exactly what you want the display to say when you do exactly this thing that makes the defect show up. Then we can code that and unless you get really creative and/or ambitious (don't!), it should be easy.


Of more concern is a flaw or defect we observed while testing, perhaps we are not yet (still not) up to speed on how it works and what all its functionality consists in.

From reset press PROG, UP and PROG

Press GREEN-3 to select... Preset 11 and see no LED or Neopixel to indicate that Preset 11 is ruling.

I didn't even know there were more than nine. I assume we missed something, so now you needa say what you want on the green button Neopixels to indicate Presets 9..16 as opposed to 1..8.

We have ideas but it's your device and I at least am too lazy to detail any. :expressionless:

Lastly, I like splash screens and rainbows, but I would suggest making anything that takes time like that be made contingent upon a constant that can be used to turn them the hell off. After a few times needing to reset to get a fresh slate for testing from a known conditions, that time starts to feel like an eternity...

Or

//    rainbow(0);     // uncomment when alto777 is no longer involved

Just sayin'.

a7

Hehe - you got it! Off for the time being...

My real-world setup is complicated (I like to make things hard for myself, huh? I should get therapy, lol) - I run stereo out of my guitar and into 2 separate amps, so think of the effects more like a STACK of 8 pedals over 8 pedals, rather than a linear 16 pedals. As such, I don't need presets 9 through 16, and the latest version I have won't allow storing to them (so far as my testing has verified, anyway). I only need effects 9 through 16 to be able to program into presets 1 through 8 alongside effects 1 through 8, which is why I made the effectBank something that only works in write mode when selecting pedals/effects.

Too late... LOL - BUT, I only played with the writeOutLCD function, and left the prior code as-is but commented out. The wokwi: https://wokwi.com/projects/388305663850086401

That screen was from my WAY earlier versions and I didn't really know what to do with it. At lunch, I made custom characters for the LCD and reimagined the screen - There are 16 effects, so the left side is FX bank 1 and the right side is FX bank 2. If an effect is chosen, a small guitar pedal shows up in the corresponding 1 through 16 slot.

I'll be honest, I'm a little proud that it's not 20+ if/then statements, which is for sure what it would have been before I went through all this, lol. It could probably be a little more elegant, but it really wasn't that far out there for me to figure out.

It's better than before, if not a little out of place from a UI stance, but it at least shows what is active, rather than what you've just hit, active or otherwise. I like having the LED and LCD in sync - nothing worse than when a guitar pedal's LED burns out or something, so it's a little added visual...

Open to thoughts as always...

Comments on 16-Loops-Personal-Final - Wokwi ESP32, STM32, Arduino Simulator

Casual play did not break anything. Besides the left bank button being on the right and vice versa everything works well so far. I'm not sure anyone here will work too hard to find anything else wrong, or to complain about.

I like the LCD 16 presets domino/feet characters.

You will probably kill a lot of the chat, but this should go right away

    Serial.print(blinkCounter);
    Serial.println("   toggle ");

If the below is for some future expansion, lose the extra characters, it is confusing. If it isn't, I can't see how the 'i'..'p' values are used. When/if you actually get keys 'i'..'p' on colPins[ ] additional columns, add them at that time. Fewer inconsistencies less head-scratching.

const byte cols = 16;


  { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p' },  // max 16 columns and max 10 rows

byte colPins[cols] = { 4, 5, 6, 7, 8, 9, 10, 11 };   // buttons or momentary switches

Gotta disagree here

theLED throws a compiler error as unused, but it's technically for the LED functions called (getEffectLED and setPresetLED) below - non-fatal, leave as-is.

theLED is not used by the function, there's no reason to pass it in, technically or otherwise. It should be removed. Again, less ink, fewer things to wonder about.


We both ask why^3 these came back out from the one realMode switch/case, or did you never move them to where they make better sense, as to make only one place where the mode is handled, and in that one place all the buttons are dealt with.

  if (realMode == READ) {     // bank buttons for presets in read mode
    if (doBank) {...

    if (doDown) {...
    
// and 

  if (realMode == WRITE) {     // bank buttons for effects in write mode
    if (doBank) {...
    
    if (doDown) {...

Place the code for those mode/button combinations with their friends doSave and doProg. Say it with me... "fewer places to look, less ink, blah blah blah".

Or not.

Anyway not bad for three weeks since the mess (!) you started with.

One question does remain and that gets back to the latching relays. As a purist I liked @gfvalvo's machine-orientated automatic relay pulse generator, and never did try to fit it into the code as I saw the relay handling as a moving target.

I've run out of the things I run out of just now, but it looks like you leave the coil baking - I do not see that after more than the switching time required the coils are returned to HIGH-HIGH or LOW-LOW between their pins one and ten.

This may not be true, and it may not be imporant. When I've used latching relays it is precisely because they latch, and can therefor be used in circumstances where power is imporant, like a battery operated device. It may be that those relays might not like too much being left in a LOW-HIGH or HIGH-LOW energized state.

So just say I've missed where they are de-energized, or justify not doing, or say you don't care and that you are sure the relays don't either.

a7

Went to a show tonight and can’t sleep, so will do my best…

EDIT - I honestly don't know why these edits are suddenly working. I can only surmise that it had something to do with the photoFET errors I was getting a few versions ago, but I have no idea... Once again, y'all haven't steered me wrong. As long as I keep the numberOfEffects to the number of pedals I have (16 in this case), the variables do the math properly. From henceforth, the number of keys is related to the number of presets (8 in this case), not effects. Definitely a game changer in flexibility, honestly. Keys i through p are effects 9 through 16. When I remove them, I’m no longer able to write those out during programming - unless I’m doing something wrong, which is probable, hehe.

EDIT - when I removed just "theLED" and left "int" it works perfectly fine. I was removing the whole thing. No compiler error. Once again, it was the littlest detail that mattered here, so thank you for being adamant. When I remove it, the LEDs no longer function properly and I got errors. I’ve read that sometimes this can happen when the compiler works faster than the code, so as long as it’s working and non-fatal, it would be fine. I’m not sure about how to fix it…

Sigh... EDIT. lol. Suddenly it's working perfectly. I can only assure you at one point it was not working quite right, and I can say it was before I went through all the compiler error stuff. I have it corrected in a separate version for the moment. I put these into their switch/cases and they worked, but there was a quirk: the bank buttons didn’t do anything on first press - I had to hit it again and then it worked - almost as if it wasn’t already in READ mode to start with. Again, I couldn’t quite figure out why or what the fix was, so I moved them back outside since that’s where they worked without issue.

The only thing still accurate from this post/reply is regarding the relays. This is still true - the NOT gate reads at ~4 to 4.25v (the relays only need about 3.75v to latch) when triggered by the optocoupler, and then goes to GND. The relays are never ā€œbaking,ā€ as it were - the LEDs represent optocouplers, and those fire a NOT gate setup on the other side, so the relays are only ever getting current to one side when the LEDs are on for 6ms at a time. Otherwise, they’re getting ground signal. Here’s my diagram:

(The ground coming from the pc817 should actually be 5v, but you get the gist). The pulse from the arduino to the opto only lets ~4.25v during the 6ms flash (I think I only need 3ms per the datasheet, but I’m accounting for any lag here), and then sets back to ground in the NOT gate. I tested with the multimeter quite a bit to ensure I wasn’t sending power to these when it wasn’t necessary and it’s working as it should…

I’ll be correcting this - in fact, with guitar pedals, everything starts on the right and moves left, but that’s an easy fix… Just have to do it in the final code.

Link to what will be the final WOKWI, which I've labeled final-FINAL, hehe - warning, rainbow is on! https://wokwi.com/projects/388391279369182209 - the only compiler errors are for the paintLCD functions - no return statement in function returning non-void, and one that says return-statement with no value, in function returning 'int'. I'll work through those, but otherwise it's... pretty finished?

**OH, and the buttons and LCD pedal selections are backwards (so button 1 will show up in slot 16 on the lcd, button 2:slot 15, etc.) - undoing and redoing the order of the LEDs and buttons at this stage is something I can do later - for now, the code is where it needs to be for the LCD. **

LOFL!

You saved me a bunch of work and a bunch of typing.

I'm in the middle of something here, but I will make sure the only thing I was wrong about was the one thing I wasn't certain about…

And I should check, but it was stupid on my part not to look closer, as far as I can tell if the coils were baking, one or the other of a red or blue tell-tale LED would be on, so.

I'll look closely at the current SOTA.

I think we near the time for

a7

Looking at

at 03:55 zulu 1 FEB 2024


Sry, I did not fully explain how to fix this. I had forgotten using a language feature I have only recently begun to exploit (we all on the learning curve, amIRight?), so all three versions need their return type changed from int to void, viz:

void paintLCD(byte screenName) {
//...

// and

void paintLCD(byte screenName, byte argument) {
//...

// and

void paintLCD(byte screenName, byte argument, byte extra) { 
//...

I see this

void memory(int theAddr, int ) {   

which I don't even know why it compiles, gonna have to investigate, but it seems to get along with this

        memory(currentBank * bankSize + numberOfPedals * key, key);  // theAddr, theLED

maybe because... I have no clue why, but it is interesting enough to run to ground. One day.

The two lines should be

// where it is defined
void memory(int theAddr) {   

// and
// where it is called
        memory(currentBank * bankSize + numberOfPedals * key);  // theAddr

As I said, lose the argument and the parameter. Both.

If that doesn't compile, or breaks something, I will fly or drive over to where you are at, you can give me your oldest and most disgusting hat and I will eat it.

Not.

But it will mean either you did not do what I said, as you had not done before,

or something else is (still) not quite right about the sketch and it is sensitive to minor changes. You should better hope not. This is the very worst kind of defect to locate, as it could literally be a seemingly innocent error in code that is 100 percent not related other than by virtue of being in the same program.

a7

Changed. Will test compiler later today on computer with Arduino software, but everything still works so I'm pretty hopeful.

Ah, there it is - removed the extra "key" in the switch case (as you've pointed out in your prior comment, which now makes sense - I was only working from where it was defined, not called) and it SEEMS to be working, but don't have time to test deeply before work. Will take a look later today...

It's saved. Ignore the added tuner button for now - I'm not sure if this is something I'll put in or not. It's basically a switch separate from the other relays so I can bypass everything to a tuner at will without having to program it with the other relays. It's just as easy to throw a normal 3pdt footswitch to handle it and not deal with the Arduino at all, but I'm toying with the idea. OR, I could just make this 9 effects again and the tuner is always only the 9th effect, but that's hack-y and requires programming. OR I'll just put the tuner before the switch and use it like a normal pedal, lol.

ordered all the parts I need (extra optos, transistors, the neoLEDs, etc.) last night. Forgot another 7805, of course, but I did find an extra - hopeful it works better than the one I've been testing with!)

It's SO close, if not done... I can feel it!