Hit momentary 1 then 1 sends data for arbitrarily named data string 11
Hit momentary 2 then 1 sends data for arbitrarily named data string 21
Hit momentary 3 then 1 sends data for arbitrarily named data string 31
Hit momentary 4 then 1 sends data for arbitrarily named data string 41
This can give up to 16 combinations i believe.
have considered it to be a waste of your time were I to attempt to show effort by putting up any code.
Grumpy_Mike!
Honoured! thank you. I am astonished when visiting your, thebox.myzen.co.uk site.
-- thank you for useful comments
Hit any 2 button and specific data (for the pair) is send only when 2nd of a pair is hit - then returns to zero state waiting for next pair to be pressed
ioflex:
Hit any 2 button and specific data (for the pair) is send only when 2nd of a pair is hit - then returns to zero state waiting for next pair to be pressed
You'll need to look up, read and understand:
Finite State Machine,
Debounce
and 'Blink without delay', if you need all 16 combinations.
You write a function that looks at the keys and returns a number from 0 to 3 when a button is pressed. You call this twice. You merge the two numbers together by shifting the first number to the left by two places and then ORing the second number with it.
This gives you a number between 0 and 15 to use as an index to your array. They are not called midi strings but midi messages.
In my oppinion there is no need to use a state machine here.
i just don't get the value times 10 plus value two part
Nobody said that.
It is the value times four. You need just one function and you call it twice in one loop.
The function will hold until a peddle is pushed, note what peddle it is and only return that number when it is released.
Start writing that function first.
In the loop call it and print out the number.
Forget about everything else just do that first and get it working.
Only then will you be ready to do the next bit.
Thank you. And, exactly on the, "Start writing that function first."
I'll hunt around, read about 'functions', 'calling a function twice in a loop'
then I'll post the hulking mess here hoping for pointers.
ioflex:
Thank you. And, exactly on the, "Start writing that function first."
I'll hunt around, read about 'functions', 'calling a function twice in a loop'
then I'll post the hulking mess here hoping for pointers.
The first button/pedal pressed will be 1, 2, 3 or 4.
Subtract 1 from the number = 0 - 3.
Multiply by 4 = 0, 4, 8 or 12 .
Put it in a variable.
Read the second button's number and subtract 1 = 0 - 3
Add it to your variable. Your variable will now contain a number from 0 to 15.
You could act on those numbers, but I like to keep 0 for 'no button pressed'.
So add 1 to your variable = 1 - 16.
Now look up the 'switch case' construct in reference.
Henry! ... and Mike! thank you for being such Stars.
I believe the only way to show effort is to post code.
I will now somewhat bravely delete from memory my relentless though failed attempts, and begin anew.
Study 'variable'
Study 'loop'
Study 'function'
Study 'switch case construct'
Study 'call variable looped twice within a function' [that's gotta be wrong - no matter - it's the effort that counts! again :-]
Reminds me of the 5 months i spent attempting daily to get jQuery's isotope to do a little web-code dance.
Should be fun!
more fun would, i believe, be having the bit I'm missing and then surrounding it with
the obvious and readily available parts, and learning in reverse, with a highly joyously motivating
somewhat working sketch, or even a, 'the clever bit's right enough', sketch.
back in a few weeks I'd think.
speaking in code -]
i currently have no option (reluctantly accepting I've exhausted hunt and peck), other than to go for it as presented.
Study 'call variable looped twice within a function
no that is call a function twice within the loop.
Here is a rough outline of the sort of structure your code must follow
void loop(){
int number1 = getPress(); // call function once
int number2 = getPress(); // call function for a second time
// merge the two numbers
// do something with the combined number
}
int getPress() { // define your own function
// do stuff in here to return the number of what has been pressed
return pressed; // return from this function the number that was pressed