Meadow.Foundation.Sensors.Hid.Mpr121
Mpr121 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var sensor = new Mpr121(Device.CreateI2cBus(Meadow.Hardware.I2cBusSpeed.Standard), 90, 100);
sensor.ChannelStatusesChanged += Sensor_ChannelStatusesChanged;
return Task.CompletedTask;
}
private void Sensor_ChannelStatusesChanged(object sender, ChannelStatusChangedEventArgs e)
{
string pads = string.Empty;
for (int i = 0; i < e.ChannelStatus.Count; i++)
{
if (e.ChannelStatus[(Mpr121.Channels)i] == true)
{
pads += i + ", ";
}
}
var msg = string.IsNullOrEmpty(pads) ? "none" : (pads + "touched");
Resolver.Log.Info(msg);
}
Sample project(s) available on GitHub
Wiring Example
To wire a Mpr121 to your Meadow board, connect the following:
Mpr121 | Meadow Pin |
---|---|
GND | GND |
SCL | D08 (SCL) |
SDA | D07 (SDA) |
VCC | 3V3 |
It should look like the following diagram: