As a proof of concept for a larger project building a drum machine,
I wired 4 buttons in a matrix with buttons 1 and 3 being powered by output 1 and buttons 2 and 4 powered by output 2, buttons 1 and 2 are read by input 1 and buttons 3 and 4 are read by input 2.
I want to alternate power to from output 1 to output 2 and back again. when input 1 receives a signal i want to light-up my first led, when input 2 receives a signal i want the second led to light up, and when both receive a signal I want the 3rd led to light up
I made a static version with only 2 buttons, where these combinations worked, but when i tried creating the matrix configuration I only got my red led powered with no response to input
This code segment leaves p1 LOW and p2 HIGH and the rest of the code always reads the b1 and b2 inputs with the p1 and p2 outputs in that state so you may as well leave them like it in the first place. Is that going to do what you want ?
Also, you would be wise not to use pins 0 and 1 in your program so that you can introduce some serial prints to help debugging.
ishkalola:
As a proof of concept for a larger project building a drum machine,
I wired 4 buttons in a matrix with buttons 1 and 3 being powered by output 1
Stop - you wired your button up to a pin to provide power to them? These are powered buttons, they have lights in them?
Perhaps I've made a mistake
I wanted to power a set of 2 buttons, which are plugged into 2 inputs. if the button is pressed the input should read HIGH as far as i understand
then i have another set of 2 buttons which plug into a second power ouput, but go into the same 2 inputs as before. I want to alternate the power between the first and second set of buttons at a rate determined by my variable resistor
You need to explain what is supposed to happen in plain language. Use terms like, "the light comes on when I press a button". Don't use terms like, "I wanted to power a set of 2 buttons, which are plugged into 2 inputs". Imagine you're writing the instructions on how to use your device in a way that an eight year old can understand.
we have 2 sets of 2 buttons
lets call them set 1 and set 2
both sets have an A button and a B button
so we have A1 B1 A2 B2
I want A1 and A2 to be read by the same input, and B1 and B2 to be read by the same input
I want set 1 to be live for a time, then set 2, but not both at once.
I want my three LEDs to respond to the combination of button presses such that if Button A is pressed I get LED1 on, If button 2 is pressed I get LED2 on, if both buttons are pressed I get LED3 on, and if neither are pressed, No lights are on.
My understanding was that in order to achive this i would set 2 pins as outputs, and use 1 of them to Power set 1 and one to power set 2, with these alternating with a delay between
One switch one pin. A person could wire two switches to a pin but I don't see any way that the Arduino could tell which is closed. Unless they are wired to an analogue pin with some resistors. We usually only think of switches as being open or closed not powered up.
Your explanation jumps around. You don't mention the LEDs when describing the hardware and you change terms when discussing the switches. You have switches so you intend for people to use the switches. How would you explain what your box does to someone who is going to use it?
this is similar to what I'm doing, but mine is 2x2
Instead of 1 button per pin, I am trialing a button matrix on a small scale. If this works i will scale it up so that i can build an array of 432 buttons with only 18 input pins, and 24 output. The output pins will alternate so that only one row of 18 buttons is being "read" at a time.
As far as this project is concerned it's just a test of the programming ideas. it will alternate between the 1st and second set of buttons being "live" "powered" or whatever the correct term for having an input voltage is. In the previous post I explained the combinations of button presses and their LED responses