Book Image

Arduino By Example

By : Adith Jagadish Boloor, Adith Jagdish Boloor
Book Image

Arduino By Example

By: Adith Jagadish Boloor, Adith Jagdish Boloor

Overview of this book

Table of Contents (18 chapters)
Arduino by Example
Credits
About the Author
Acknowledgements
About the Reviewers
www.PacktPub.com
Preface
Index

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"); 
}


// =======...