Search
  • 1/4" Jack Of All Trades

Physical Computing Week 8: Simple Gesture Controlled LEDs

Lab Video


Using the Arduino nano33 BLE sense and the APDS9960 library I made a simple gesture sensor that controls 4 LEDs, 1 for each gesture direction ( up [yellow], down [yellow], left [green], right [red] ). Not sure how/if I could use any of the Nano's sensors in my final project, but still had quite a lot fun playing around with it. The development of my final project took precedent.


Gesture controls featured in my short story about the library, so that influenced my decision to experiment with that particular feature of the nano. The next stage of the story is going to be an interrogation scene and I did not think designing a gadget for this purpose was particularly ethical!


Although I did not have time to get into the ML aspect of the nano this week, I do intend on exploring it in the future.


Here is the code for my gesture controller:


#include <Arduino_APDS9960.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!APDS.begin()) {
    Serial.println("Error initializing APDS9960 sensor!");
  }

  
  APDS.setGestureSensitivity(70);

  Serial.println("Detecting gestures ...");
}
void loop() {
  if (APDS.gestureAvailable()) {
    int gesture = APDS.readGesture();

    switch (gesture) {
      case GESTURE_UP:
        Serial.println("Detected UP gesture");
        digitalWrite(12, HIGH);
        delay(50);
        digitalWrite(12, LOW);
        break;

      case GESTURE_DOWN:
        Serial.println("Detected DOWN gesture");
        digitalWrite(11, HIGH);
        delay(50);
        digitalWrite(11, LOW);
        break;

      case GESTURE_LEFT:
        Serial.println("Detected LEFT gesture");
        digitalWrite(10, HIGH);
        delay(50);
        digitalWrite(10, LOW);
        break;

      case GESTURE_RIGHT:
        Serial.println("Detected RIGHT gesture");
        digitalWrite(9, HIGH);
        delay(50);
        digitalWrite(9, LOW);
        break;

      default:
        break;
    }
  }
}


5 views0 comments