Hello! sorry for the inconvenience...
Here is the code. I tried to make some changes to the "button" example in digital examples inside IDE, but I think I did something wrong.
// this constant won't change:
const int pad1 = A0;
const int pad2 = A1;
const int pad3 = A2;
const int pad4 = A3;
const int pad5 = A4;
const int pad6 = A5;
const int pad7 = 0;
const int pad8 = 1;
// outputs
const int outpad1 = 13;
const int outpad2 = 12;
const int outpad3 = 11;
const int outpad4 = 10;
const int outpad5 = 9;
const int outpad6 = 8;
const int outpad7 = 7;
const int outpad8 = 6;
int pad1s = 0; // current state of the button
int pad2s = 0;
int pad3s = 0;
int pad4s = 0;
int pad5s = 0;
int pad6s = 0;
int pad7s = 0;
int pad8s = 0;
int pad1ls = 0; // previous state of the button
int pad2ls = 0;
int pad3ls = 0;
int pad4ls = 0;
int pad5ls = 0;
int pad6ls = 0;
int pad7ls = 0;
int pad8ls = 0;
void setup() {
// initialize the button pin as a input:
pinMode(pad1, INPUT);
pinMode(pad2, INPUT);
pinMode(pad3, INPUT);
pinMode(pad4, INPUT);
pinMode(pad5, INPUT);
pinMode(pad6, INPUT);
pinMode(pad7, INPUT);
pinMode(pad8, INPUT);
// initialize the LED as an output:
pinMode(outpad1, OUTPUT);
pinMode(outpad2, OUTPUT);
pinMode(outpad3, OUTPUT);
pinMode(outpad4, OUTPUT);
pinMode(outpad5, OUTPUT);
pinMode(outpad6, OUTPUT);
pinMode(outpad7, OUTPUT);
pinMode(outpad8, OUTPUT);}
void loop() {
// read the pushbutton input pin:
pad1s = digitalRead(pad1);
pad2s = digitalRead(pad2);
pad3s = digitalRead(pad3);
pad4s = digitalRead(pad4);
pad5s = digitalRead(pad5);
pad6s = digitalRead(pad6);
pad7s = digitalRead(pad7);
pad8s = digitalRead(pad8);
// compare the buttonState to its previous state
if (pad1s = pad1ls) {
// if the state has changed, increment the counter
if (pad1s == HIGH) {
digitalWrite(outpad1, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad1, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad1ls = pad1s;
if (pad2s = pad2ls) {
// if the state has changed, increment the counter
if (pad2s == HIGH) {
digitalWrite(outpad2, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad2, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad2ls = pad2s;
if (pad3s = pad3ls) {
// if the state has changed, increment the counter
if (pad3s == HIGH) {
digitalWrite(outpad3, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad3, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad3ls = pad3s;
if (pad4s = pad4ls) {
// if the state has changed, increment the counter
if (pad4s == HIGH) {
digitalWrite(outpad4, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad4, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad4ls = pad4s;
if (pad5s = pad5ls) {
// if the state has changed, increment the counter
if (pad5s == HIGH) {
digitalWrite(outpad5, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad5, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad5ls = pad5s;
if (pad6s = pad6ls) {
// if the state has changed, increment the counter
if (pad6s == HIGH) {
digitalWrite(outpad6, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad6, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad6ls = pad6s;
if (pad7s = pad7ls) {
// if the state has changed, increment the counter
if (pad7s == HIGH) {
digitalWrite(outpad7, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad7, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad7ls = pad7s;
if (pad8s = pad8ls) {
// if the state has changed, increment the counter
if (pad8s == HIGH) {
digitalWrite(outpad8, HIGH);
} else {
// if the current state is LOW then the button went from on to off:
digitalWrite(outpad8, LOW);
}
// Delay a little bit to avoid bouncing
delay(20);
}
// save the current state as the last state, for next time through the loop
pad8ls = pad8s;
}
please note that the "pads" are the seperate drum triggers.
sterretje:
The Pi is a 3.3V device to my knowledge; can the inputs handle 5V ?
Or did you take precautions?
yes, I did, Thank you!