Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Arduino By Example

You're reading from   Arduino By Example Design and build fantastic projects and devices using the Arduino platform

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785289088
Length 242 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
 Adith Jagadish Boloor Adith Jagadish Boloor
Author Profile Icon Adith Jagadish Boloor
Adith Jagadish Boloor
 Boloor Boloor
Author Profile Icon Boloor
Boloor
Arrow right icon
View More author details
Toc

Pattern recognition


Firstly, go ahead and create this circuit:

Touch pad circuit (credits: Lauren, DFRobot)

Your capacitive touch pad and its controller (the central component in the image), are connected using the corresponding numbers labeled on the pins. The connections from the Arduino to the controller are as follows (literally the same connections as before):

  • GND – GND

  • VCC – 5V

  • SCL – A5 (analog pin 5)

  • SDA – A4

  • IQR – D2 (digital pin 2)

  • ADDR – no connection necessary

Do not worry if the touch pad doesn't look exactly like this; as long as the connections are fine, everything will work out.

Open up Arduino and go to File | Examples | MPR121 | Examples | Touchpad or copy the following code:

#include <Wire.h>
#include <mpr121.h>

int X ;           // X-coordinate
int Y ;           // Y-coordinate

// =========  setup  =========
void setup()
{ 
  //  initialize function
  Serial.begin(19200);
  Wire.begin();
  CapaTouch.begin();

  delay(500);
  Serial.println("START"); 
}


// =======...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime
Visually different images