Summary of Contents for sparkfun ZX Distance and Gesture Sensor
Page 1
ZX Distance and Gesture Sensor SMD Hookup Guide Introduction The ZX Distance and Gesture Sensor is a collaboration product with XYZ Interactive. The innovative people at XYZ Interactive have created a unique technology that allows for simple infrared (IR) beams to be used to detect an object’s location in two dimensions.
SparkFun Wish List ZX Distance and Gesture Sensor SEN-13162 The ZX Distance and Gesture Sensor is a touchless sensor that is ca… SparkFun RedBoard - Programmed with Arduino DEV-13975 At SparkFun we use many Arduinos and we're always looking for the…...
Page 3 of 16 • How to Install FTDI Drivers – If you are programming an Arduino or using the ZX Sensor demo app, chances are you will need to use an FTDI Board Overview The ZX Sensor works by bouncing infrared (IR) beams of light from the two LEDs on either side off of an object above the sensor.
Page 4 of 16 Open 0x10 Closed 0x11 Hardware Hookup Add Headers Solder a row of male headers to the nine headers holes on the board. To keep the board from tilting while soldering, place the unused break away headers sideways under the board. Heads up! Do not solder headers to the row of holes at the top of the board.
Page 5
D O W N L O A D T H E Z X S E N S O R AR D U I N O LI B R AR Y ! Unzip the downloaded file. Follow this guide on installing Arduino libraries to install the files as an Arduino library. https://github.com/sparkfun/SparkFun_ZX_Distance_and_Gesture_Sensor_Arduino_Library/archive/master.zip...
Page 6
Page 6 of 16 Arduino: ZX Example Load the ZX Demo Open up the Arduino program and select File → Examples → SparkFun_ZX_Distance_and_Gesture_Sensor → I2C_ZX_Demo. Attach a USB mini cable from your computer to the RedBoard. If you have not previously done so, install the FTDI drivers. For reference, here is the I2C_ZX_Demo.ino sketch.
Page 7
5V VCC Power GND GND Ground A4 DA I2C Data A5 CL I2C Clock 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 SparkFu n employee) at the local, and you've found our code helpfu l, please buy us a round! Distributed asis; no warranty is given. ********************************************************** ******/ #include <Wire.h> #include <ZX_Sensor.h> // Constants const int ZX_ADDR = 0x10; // ZX Sensor I2C address // Global Variables ZX_Sensor zx_sensor = ZX_Sensor(ZX_ADDR); uint8_t x_pos; uint8_t z_pos; void setup() { uint8_t ver; // Initialize Serial port Serial.begin(9600); Serial.println(); Serial.println(""); Serial.println("SparkFun/GestureSense I2C ZX Demo"); Serial.println(""); // Initialize ZX Sensor (configure I2C and read model I...
Page 8
Page 8 of 16 if ( zx_sensor.init() ) { Serial.println("ZX Sensor initialization complete"); } else { Serial.println("Something went wrong during ZX Sensor init!"); } // Read the model version number and ensure the library will work ver = zx_sensor.getModelVersion(); if ( ver == ZX_ERROR ) { Serial.println("Error reading model version number"); } else { Serial.print("Model version: "); Serial.println(ver); } if ( ver != ZX_MODEL_VER ) { Serial.print("Model version needs to be "); Serial.print(ZX_MODEL_VER); Serial.print(" to work with this library. Stopping."); while(1); } // Read the register map version and ensure the library will work ver = zx_sensor.getRegMapVersion(); if ( ver == ZX_ERROR ) { Serial.println("Error reading register map version num ber");...
Page 9
Page 9 of 16 Click the Upload button and wait for the program to finish uploading to the Arduino. Select Tools → Serial Monitor to open up the serial terminal. More info on the Serial Terminal can be found here. Note that the Serial Monitor settings are the default settings (9600, 8, n, 1).
Page 10
Page 10 of 16 Here is the I2C_Gesture_Interrupt.ino sketch for reference.
Page 11
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 asis; no warranty is given. ************************************************************** #include <Wire.h>...
Page 12
Page 12 of 16 // Initialize Serial port Serial.begin(9600); Serial.println(); Serial.println(" "); Serial.println("SparkFun/GestureSense I2C Gesture Interrup t"); Serial.println("Note: higher 'speed' numbers mean slower"); Serial.println(" "); // Initialize ZX Sensor (configure I2C and read model ID) if ( zx_sensor.init(GESTURE_INTERRUPTS) ) { Serial.println("ZX Sensor initialization complete"); } else { Serial.println("Something went wrong during ZX Sensor ini t!"); } // Read the model version number and ensure the library wil l work ver = zx_sensor.getModelVersion(); if ( ver == ZX_ERROR ) { Serial.println("Error reading model version number"); } else { Serial.print("Model version: "); Serial.println(ver); } if ( ver != ZX_MODEL_VER ) { Serial.print("Model version needs to be ");...
Page 13
Page 13 of 16 // Clear the interrupt flag interrupt_flag = false; // You MUST read the STATUS register to clear interrupt! zx_sensor.clearInterrupt(); // Read last gesture gesture = zx_sensor.readGesture(); gesture_speed = zx_sensor.readGestureSpeed(); switch ( gesture ) { case NO_GESTURE: Serial.println("No Gesture"); break; case RIGHT_SWIPE: Serial.print("Right Swipe. Speed: "); Serial.println(gesture_speed, DEC); break; case LEFT_SWIPE: Serial.print("Left Swipe. Speed: "); Serial.println(gesture_speed, DEC); break; case UP_SWIPE: Serial.print("Up Swipe. Speed: "); Serial.println(gesture_speed, DEC); break; default: break; } } } void interruptRoutine() { interrupt_flag = true;...
Page 14 of 16 If you performed the gesture correctly, you should see a message appear in the Serial Monitor. NOTE: The "Speed" of the gesture is a measure of how fast the gesture occurred. Note that the lower the number, the faster the gesture occurred (e.g.
Page 15
Page 15 of 16 Setup Connect the FTDI Breakout board to the ZX Sensor. Ensure the pins on the FTDI Brekaout line up with the pins on the ZX Sensor (e.g. GRN connects to GRN and BLK connects to BLK). Connect the FTDI Breakout to your computer with a USB cable.
Page 16
Make bright, colorful displays using Guide the 32x32 and 32x16 RGB LED Getting started guide for the Avago panels. This hookup guide shows APDS-9960 color, proximity, and how to hook up these panels and gesture sensor. control them with an Arduino. https://learn.sparkfun.com/tutorials/zx-distance-and-gesture-sensor-smd-hookup-guide?_ga... 6/6/2017...
Need help?
Do you have a question about the ZX Distance and Gesture Sensor and is the answer not in the manual?
Questions and answers