
}
else if (touchstatus & (1<<THREE))
{
digits = '3';
}
Serial.println(digits);
}
//do nothing if more than one button is pressed, or if all a
re released
else if (touchNumber == 0)
;
else
;
}
The function
getTouchStatus()
actually returns at 16-bit value which gives
the status of each button. The status of 1 indicates that an electrode is
being activated.
language: c
int getTouchStatus()
{
int touch;
touch = mpr121Read(0x01) << 8;
touch |= mpr121Read(0x00);
return touch;
}
Now that you have basic communication up and running with your shield,
you can start integrating this into projects. If you haven’t yet connected
anything to electrodes 9, 10 and 11, consider adding in additional buttons
here. You will also need to update the code. You’ll want to add the following
block of code into the example sketch right before
Serial.println(digits);
. You can change the digits values to have the
buttons output different values instead of “A”, “B”, or “C”.
Page 14 of 24