sparkfun ZX Distance and Gesture Sensor Hook-Up Manual page 11

Table of Contents

Advertisement

Page 11 of 16
/*************************************************************
*** 
I2C_Gesture_Interrupt.ino 
XYZ Interactive ZX Sensor 
Shawn Hymel @ SparkFun Electronics 
May 6, 2015 
https://github.com/sparkfun/SparkFun_ZX_Distance_and_Gesture_S
ensor_Arduino_Library 
Tests the ZX sensor's ability to read gesture data over I2C us
ing  
an interrupt pin. This program configures I2C and sets up an 
interrupt to occur whenever the ZX Sensor throws its DR pin hi
gh. 
The gesture is displayed along with its "speed" (how long it t
akes 
to complete the gesture). Note that higher numbers of "speed" 
indicate a slower speed. 
Hardware Connections: 
 Arduino Pin  ZX Sensor Board  Function 
 ­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ 
 5V           VCC              Power 
 GND          GND              Ground 
 A4           DA               I2C Data 
 A5           CL               I2C Clock 
 2            DR               Data Ready 
Resources: 
Include Wire.h and ZX_Sensor.h 
Development environment specifics: 
Written in Arduino 1.6.3 
Tested with a SparkFun RedBoard 
This code is beerware; if you see me (or any other SparkFun  
employee) at the local, and you've found our code helpful, ple
ase 
buy us a round! 
Distributed as­is; no warranty is given. 
**************************************************************
**/
#include <Wire.h>
#include <ZX_Sensor.h>
// Constants
const int ZX_ADDR = 0x10;    // ZX Sensor I2C address
const int INTERRUPT_NUM = 0; // Pin 2 on the UNO
// Global Variables
ZX_Sensor zx_sensor = ZX_Sensor(ZX_ADDR);
volatile GestureType gesture; 
volatile bool interrupt_flag;
uint8_t gesture_speed; 
void setup() {
  uint8_t ver; 
// Initialize gesture to no gesture
  gesture = NO_GESTURE;

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ZX Distance and Gesture Sensor and is the answer not in the manual?

Subscribe to Our Youtube Channel

Related Products for sparkfun ZX Distance and Gesture Sensor

This manual is also suitable for:

Sen-13162

Table of Contents