tim3lord 0 Posted February 17, 2019 Share Posted February 17, 2019 Hello, I am trying to port Sparkfun's library to get the apds-9960 Gesture Sensor working on my Tiva C 1294 board. I set up the library like you normally would with ardunio while changing the interrupt pin and uploaded the code to my board with no issues. The only problem is when I go to serial monitor I get nothing printed to screen. Are there any other steps I need to take in order to convert this code to work on my Tiva board? I also tried moving to code composer studio but I cant find many clean tutorials on how to use it. I also have a MSP432 that I might try to get his working on if its supported better. Thanks! /**************************************************************** GestureTest.ino APDS-9960 RGB and Gesture Sensor Shawn Hymel @ SparkFun Electronics May 30, 2014 https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor Tests the gesture sensing abilities of the APDS-9960. Configures APDS-9960 over I2C and waits for gesture events. Calculates the direction of the swipe (up, down, left, right) and displays it on a serial console. To perform a NEAR gesture, hold your hand far above the sensor and move it close to the sensor (within 2 inches). Hold your hand there for at least 1 second and move it away. To perform a FAR gesture, hold your hand within 2 inches of the sensor for at least 1 second and then move it above (out of range) of the sensor. Hardware Connections: IMPORTANT: The APDS-9960 can only accept 3.3V! Arduino Pin APDS-9960 Board Function 3.3V VCC Power GND GND Ground A4 SDA I2C Data A5 SCL I2C Clock 2 INT Interrupt Resources: Include Wire.h and SparkFun_APDS-9960.h Development environment specifics: Written in Arduino 1.0.5 Tested with SparkFun Arduino Pro Mini 3.3V This code is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! Distributed as-is; no warranty is given. ****************************************************************/ #include <Wire.h> #include <SparkFun_APDS9960.h> // Pins #define APDS9960_INT PE_4 // Needs to be an interrupt pin // LED #define LED PN_0 // Constants // Global Variables SparkFun_APDS9960 apds = SparkFun_APDS9960(); int isr_flag = 0; void setup() { pinMode(LED, OUTPUT); // Set interrupt pin as input pinMode(APDS9960_INT, INPUT); Wire.setModule(0); Wire.begin(); // Initialize Serial port Serial.begin(9600); Serial.println(); Serial.println(F("--------------------------------")); Serial.println(F("SparkFun APDS-9960 - GestureTest")); Serial.println(F("--------------------------------")); // Initialize interrupt service routine attachInterrupt(0, interruptRoutine, FALLING); // Initialize APDS-9960 (configure I2C and initial values) if ( apds.init() ) { Serial.println(F("APDS-9960 initialization complete")); } else { Serial.println(F("Something went wrong during APDS-9960 init!")); } // Start running the APDS-9960 gesture sensor engine if ( apds.enableGestureSensor(true) ) { Serial.println(F("Gesture sensor is now running")); } else { Serial.println(F("Something went wrong during gesture sensor init!")); } } void loop() { if( isr_flag == 1 ) { detachInterrupt(0); handleGesture(); isr_flag = 0; attachInterrupt(0, interruptRoutine, FALLING); } } void interruptRoutine() { isr_flag = 1; } void handleGesture() { if ( apds.isGestureAvailable() ) { switch ( apds.readGesture() ) { case DIR_UP: Serial.println("UP"); digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second break; case DIR_DOWN: Serial.println("DOWN"); digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second break; case DIR_LEFT: Serial.println("LEFT"); digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second break; case DIR_RIGHT: Serial.println("RIGHT"); digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second break; case DIR_NEAR: Serial.println("NEAR"); digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second break; case DIR_FAR: Serial.println("FAR"); digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second break; default: Serial.println("NONE"); } } } Quote Link to post Share on other sites
Rei Vilo 695 Posted February 17, 2019 Share Posted February 17, 2019 Have you gone through the I²C Check-List? Quote Link to post Share on other sites
tim3lord 0 Posted February 17, 2019 Author Share Posted February 17, 2019 @Rei Vilo Yes, I the sensor runs on 3.3v and I set Wire.setModule(0); Wire.begin(); in void setup() I have my wires hooked into SCL (0) and SDA (0) Quote Link to post Share on other sites
Manm31 0 Posted February 8, 2020 Share Posted February 8, 2020 Hi, any success?I have the same issue:( Quote Link to post Share on other sites
Rei Vilo 695 Posted February 9, 2020 Share Posted February 9, 2020 Pull-up resistors? Quote Are pull-ups installed? Try 10, 4.7 or 2.2 kΩ for the SDA and SCL lines. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.