SEN-09695

SEN-09695

  • 厂商:

    SPARKFUNELECTRONICS

  • 封装:

    -

  • 描述:

    MPR121 Touch, Capacitive Sensor Evaluation Board

  • 数据手册
  • 价格&库存
SEN-09695 数据手册
Page 1 of 24   MPR121 Hookup Guide CONTR IBUTORS: TONI_K MPR121 Overview If you are interested in adding the ‘magic’ of touch to control your electronics project, a capacitive touch sensor might be the way to go. This hookup guide will show you how to use the MPR121QR2 sensor. The MPR121QR2 is a capacitive touch sensor controller that makes it very easy to integrate capacitive touch sensing into your project. It communicates via I2C, and works by measuring the capacitance of twelve electrode points. When an object comes close to the electrode connector, the measured capacitance changes. This signals the MPR121 that something has touched a ‘button’. The IC is also capable of driving LEDs or basic GPIO functionality on electrode pins 4 through 11, giving you a lot of freedom for setting up your project. The sensor works from 1.6V to 3.3V. The sensor isn’t very current-hungry, drawing only around 29 µA when sampling every 16 milliseconds. Materials To work through this tutorial, you are going to need one of the three versions of the MPR121 sensor: • MPR121 Capacitive Touch Sensor Breakout Board • Touch Shield • MPR121 Capacitive Touch Keypad You will also want a soldering iron, some hookup wires and a microcontroller capable of I2C communication. For our examples, we will be using an Arduino Uno. You will also need some kind of material to act as a capacitive sensing surface (also known as an electrode, which is not to be confused with the character Electrode). Generally, aluminum foil works well. However, you could also use coins, conductive paint, or copper tape. Page 2 of 24 Suggested Reading The MPR121 is very easy to get started using, especially with the example code. However, if you haven’t worked with Arduino previously or aren’t familiar with I2C communication, you should check out the tutorials below. • • • • What is an Arduino I2C Communication How to Use a Breadboard How to Solder Capacitive Touch Sensor Breakout Board The breakout board is the most versatile option of the three MPR121 products. You can wire it up to any kind of electrode you want, and, as it is a simple breakout board, does not have a particular microcontroller footprint it favors. The breakout board has 4 pins that need to be connected to your microcontroller at a minimum to get communication going: the power lines and the I2C lines. However, for our example, we are going to be also connecting the IRQ pin to more easily detect a change on one of the electrodes. Connections MPR121 Breakout → Arduino Uno • 3.3V → 3.3V • SCL → A5 • SDA → A4 Page 3 of 24 • GND → GND • IRQ → D2 You will also want to connect the Electrode/LED pins to your electrode material you selected previously. You will want to make sure you have a good, solid connection between your material and your board, so make sure you thoroughly solder your connections. Check out the Fritzing diagram below for how your connections should look. The yellow squares represent whatever material you decide to use for your electrodes. Communicating with the Breakout Board To communicate with your breakout board, you will need the Arduino sketch available as a zip file here. Alternatively, you can also find the most up-to-date firmware for working with the breakout board available on GitHub. Let’s take a look and see exactly what the code is doing. #include "mpr121.h" #include  int irqpin = 2;  // Digital 2 boolean touchStates[12]; //to keep track of the previous t ouch states In this first section of the code, the MPR121 library and the Wire library are initialized. The Wire library makes I2C communication easy to use on the Arduino. The sketch also defines digital pin 2 as the IRQ pin connection, and creates 12 instances of the boolean variable touchStates. For the second section of the code, we define the irqpin as an INPUT, telling the Arduino to monitor the digital signal coming in over that pin. Serial communication is also started at 9600 bps, s well as the Wire and mpr121 libraries. Page 4 of 24 void setup(){ pinMode(irqpin, INPUT); digitalWrite(irqpin, HIGH); //enable pullup resistor         Serial.begin(9600);         Wire.begin(); mpr121_setup();     }  The main loop of the code is incredibly simple, as it only calls a single function. void loop(){ readTouchInputs();     }  The function is actually described in the next section of the code. The Arduino requests the electrode states from the sensor in the first section, and the least significant bits and most significant bits are defined for the sensor. Page 5 of 24 void readTouchInputs(){ if(!checkInterrupt()){ //read the touch state from the MPR121     Wire.requestFrom(0x5A,2);      byte LSB = Wire.read();     byte MSB = Wire.read();     uint16_t touched = ((MSB 
SEN-09695 价格&库存

很抱歉,暂时无法提供与“SEN-09695”相匹配的价格&库存,您可以联系我们找货

免费人工找货