Gesture Sensor Help
NWCCTV
Posts: 3,629
In the attached code everything works fine but I have a bit of an issue. At the end of the code I input an IF statement to flash an LED on Pin 13 when sampleCount > 100. The problem is that sampleCount seems to increment automatically. So, I need to figure out what command to use for the ALS VIS, ALS IR, PS1, PS2 and PS3 values since they see the ones to increase and decrease as my hand moves in front of the device. Thanks.
{{ File: Si1143_Sensor_Demo.spin Version: 1.0 Date: March 14, 2012 Author: Kevin McCullough Company: Gecko Engineering "Turning good ideas into great products." Phone: 541.660.2314 Email: [EMAIL="Kevin@GeckoEngineering.com"]Kevin@GeckoEngineering.com[/EMAIL] Web: [URL="http://www.GeckoEngineering.com"]www.GeckoEngineering.com[/URL] Revision History: v1.0 - 3/14/2012 Initial release. Description: This object demonstrates the use of the Si1143.spin driver for the "Si1143 Proximity Sensor" (Parallax PN: 28046). In this simple demo, the application runs in a loop and manually polls the driver for new measurements, then prints the values out to the serial terminal. Connection Diagram: VIN = 3.3V ┌──────┐ ┬ ┬ ┬ ┬ ┌────────────────┐ │ │ │ │ │ │ │ [‣] │ │ │ R R R ┌─┼─┤GND │ │ │ │ │ │  └─┤VIN ┌─────────┘ │ P2├───┻───┼───┼────────┤INT │ │ P1├───────┻───┼────────┤SCL │ │ P0├───────────┻────────┤SDA │ │ │ │ │ └──────┘ └──────┘ Propeller MCU Si1143 Proximity (P8X32A) Sensor (28046) R = 4.7kΩ }} CON _clkmode = xtal1 + pll16x _clkfreq = 80_000_000 'Pins used to connect to the "Si1143 Proximity Sensor" module SDA_PIN = 0 SCL_PIN = 1 INT_PIN = 2 CURSOR_X = 10 'This value sets the left alignment for printing all the values OBJ sensor : "Si1143" debug : "FullDuplexSerial" pin : "Input Output Pins" time : "Timing" VAR long samples[5] long sampleCount PUB RunDemo | index 'Start the serial terminal to display debug text debug.Start(31, 30, 0, 115200) 'Start the Si1143 device driver sensor.Start(SDA_PIN, SCL_PIN, INT_PIN) 'Store the baseline average offset values (accomodates for optical leakage 'between the LEDs and the sensor). sensor.PsBaselineSet 'NOTE: THIS LINE CAN BE COMMENTED OUT TO GET 'THE RAW VALUES FOR PS1, PS2, & PS3 'Print startup text to the terminal debug.tx(0) debug.str(string("==================")) debug.tx(13) debug.str(string("Si1143 Sensor Demo")) debug.tx(13) debug.str(string("==================")) debug.tx(13) debug.str(string("Sample# = ")) debug.tx(13) debug.str(string("ALS VIS = ")) debug.tx(13) debug.str(string("ALS IR = ")) debug.tx(13) debug.str(string("PS1: = ")) debug.tx(13) debug.str(string("PS2: = ")) debug.tx(13) debug.str(string("PS3: = ")) 'Stay in this loop and take measurements forever repeat 'Get a new set of samples sampleCount := sensor.SampleOnce(@samples) 'Display the sample count value debug.tx(2) 'Position cursor (x,y) debug.tx(CURSOR_X) 'X debug.tx(3) 'Y debug.dec(sampleCount) 'Display value debug.str(string(" ")) 'Display all the sample values returned in the array repeat index from 0 to 4 debug.tx(2) 'Position cursor (x,y) debug.tx(CURSOR_X) 'X debug.tx(index + 4) 'Y debug.dec(samples[index]) 'Display value debug.str(string(" ")) if sampleCount > 100 pin.High(13) time.Pause(200) pin.Low(13) time.Pause(200)
Comments
This is a shortcut to this (don't enter the code below into the program):
Now that you have name for the index numbers you can use:
You would also need the detector chip, (Si1143), uncovered. It's the chip above LED1 with the transparent window.
http://www.parallax.com/sites/default/files/downloads/28046-Si1143-Gesture-Sensor-v1.2.pdf
Just kidding.