hi, thank to everybody for giving me advice regarding my 16 switch MIDI-Footswitch .
i've run into the next issue.
what I tried to achieve with this code is: have each switch go through different states: first press: record, second: playing, third: stopped, then toggle between play/stop.
if it's playing or stopped: Recording if pressed for more than 0.7 seconds.
and IT WORKS! i think...
but NOT with switches connected to 6, 9, 10 and 13.
they always start with „Playing“ and I can't figure out why.
I redid your if/else thing as a switch/case, which for me makes it easier to read. If I didn't make a mistake it should be logically identical, it seems to (mis)behave the 'xact same way.
I added to you printed text so it is easier to see what is recording, playing &c.
The read button is debounced, the green button is not.
hi ninora, I'm using a teensy 4.0.
i connected 16 pushbuttons with Resistors and Condensors (seemingly the right way an right values..)
I do not get any bouncing (like on/off a couple of times with only one press)
and the Setup worked flawless with a different code...
Ok, things are getting even weirder.
If i interchange the physical Buttons, the error remains.
i.e. pin 6 still always starts with „Playing“, not „Recording“.
And to make things even worse:
when I disconnect the teensy from my MAC and reconnect (aka power off an on again)
ALL Switches start with PLAYING.
When I just reset with the built in Button, they start with RECORDING with the usual exception of 6, 9, 10, 13.
Well every switch the same; if it's what you want, then you good.
And I see that you have some kind of hardware resistor-capacitor denouncing learned the hard way, so again looks like you good.
Didja take a peek at the wokwi simulator version I linked above, and also your logic recast as a switch/case?
If you are looking to up game programming switch/case is very easy to add to your tool kit. And as I said, it makes the flow in exact this circumstance easier to read. And write, you may find.
#include <ezButton.h> // ezButton library
ezButton button(7); // create Button object that attach to pin 7;
void setup() {
button.setDebounceTime(50); // set debounce time to 50 milliseconds
}
void loop() {
button.loop(); // MUST be at the top of the loop() function
if(button.isPressed())
// Do something
}```
had a look at wokwi, looks interesting.
Your code seems to work just fine.
my next step is using ezButton to check if there is any misbehaving of the suspected switches with a different code also
and i will test the whole thing with my stock arduino, maybe....
so I got 4 Loopers and 4 Playbacks
next step:
make one switch the „stop and Erase“ for the Looper that recorded last.
If you don't mind I'll keep you updated.
Thomas
another
If you have a moment and any curiosity on par with mine, could you do something very simple to test those pins that don't work configured as inputs?
Maybe just read a pin, and print its value.
Pins should not randomly work or not work.
Is it possible you damaged your board earlier when you knew less about what you were up to, or accidentally? Do you have another board you could test?
It is of slight importance; if you did damage your board, however, it may mean that other pins have been "wounded" and may go dodgy on you during the big performance…
well, the pins are read properly, I guess.
the weird thing is that pins 6,9,10 & 13 react:
„yes, I have been pressed. and now there is this Variable that has a Value.
well, I don't care, I add 1 to it.
on the Teensy one pin can have multiple functions, maybe there is something wrong deep in the guts of this thing I don't know about yet.
I will use a brand-new Unit one the final Product.
And I will try a stock Arduino uno or Mega if I am able to configure it the way that it is seen a a Midi device by my computer as the teensy is by nature.
You care more than I do, I hope. But are you guessing?
Did you simply read a pin, and print the value? For a "good" pin, to check the code, and for "bad" ones to see if they are bad?
Could you have damaged your board?
Now I am going to guess that there is nothing special about those pins that you wouldn't have to go out of your way to set up, but I do not know the teensy, so.
A practical solution you have found, avoid those pins. Pratical but unsatisfying.
BTW and FWIW, I would be surprised if another Arduino couldn't serve; as I found early on in this or another of your undertakings the teensy comes out of the box with MIDI. Other boards may need a library installed to achieve the same functionality.