Is there a way to send a signal to 2 different pins with one cap touch button in a sequence? For instance if the first sensor is touched, can that be programmed to send a signal to pins 20 and 40 and the next sensor to 21/41 and so on?
#include <Wire.h>
#include "Adafruit_MPR121.h"
Adafruit_MPR121 cap = Adafruit_MPR121();
uint16_t lasttouched = 0;
uint16_t currtouched = 0;
int pins[] = {(20,40)(21,41)(22,42)(23,43)};
void setup() {
pinMode(20, OUTPUT);
pinMode(21, OUTPUT);
pinMode(22, OUTPUT);
pinMode(23, OUTPUT);
pinMode(40, OUTPUT);
pinMode(41, OUTPUT);
pinMode(42, OUTPUT);
pinMode(43, OUTPUT);
if (!cap.begin(0x5A)) {
while (1);
}
}
void loop() {
currtouched = cap.touched();
for (uint8_t i=0; i<12; i++) {
if ((currtouched & _BV(i)) && !(lasttouched & _BV(i)) ) {
digitalWrite(20+i, LOW);
}
if (!(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {
digitalWrite(20+i, HIGH);
}
}
lasttouched = currtouched;
}