Teensy 10 Degrees of Freedom "Prop Shield" sensor board with LEDs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Teensy 10 Degrees of Freedom "Prop Shield" sensor board with LEDs

Teensy 10 Degrees of Freedom "Prop Shield" sensor board with LEDs

Teensy Prop Shield : Motion activated Light

This demo shows a basic gesture controlled light sequence using NXP motion sensors available in the Teensy Prop Shield

LED lights can be found on the following link: https://www.adafruit.com/product/2238

Features

The Teensy Prop Shield is an add-on sensor shield board for the Teensy 3.1 which is an USB based microcontroller development platform. The Teensy 3.1 has a 32 bit ARM Cortex M4 processor from NXP -MK20DX256. The board can be programmed using Arduino IDE + Teensyduino plugin.

The prop shield consists of the following devices:

  • Motion Sensors - Allows motion interactive light & sound.
  • Audio Amplifier - Clear quality audio output to a small speaker.
  • Fast LED Driver - Drive APA102 / Dotstar LEDs for colorful lighting with rapid response.
  • Flash Memory - 8 Mbyte storage for images, sound clips, and data logging\

Featured NXP products

  • FXOS8700CQ - 6 Axis Linear Accelerometer & Magnetometer
  • FXAS21002C   - 3 Axis Digital Angular Rate Gyroscope
  • MPL3115A2     - Precision Pressure/Altitude & Temperature sensor
  • MK20DX256   - 32 bit ARM Cortex M4 processor

Demo Setup:

Wiring[1] :

pastedImage_54.png
pastedImage_42.png

Software:

After setup, Download Arduino IDE and Teensyduino add on and follow the instructions as defined in the page below

http://www.pjrc.com/teensy/td_download.html

Note: Arduino version used for this demo:  1.6.8.

Run the “Teensy_RGB_Led_Strip.ino” sketch attached.

Sample Code:

// Full orientation sensing using NXP's advanced sensor fusion algorithm. 

// 

// You *must* perform a magnetic calibration before this code will work. 

// 

// To view this data, use the Arduino Serial Monitor to watch the 

// scrolling angles, or run the OrientationVisualiser example in Processing. 

 

 

#include <NXPMotionSense.h> 

#include <Wire.h> 

#include <EEPROM.h> 

#include <FastLED.h> 

 

 

#define NUM_LEDS 60 

CRGB leds[NUM_LEDS]; 

 

 

NXPMotionSense imu; 

NXPSensorFusion filter; 

int a; 

int acc_rms; 

void setup() { 

  Serial.begin(9600); 

  imu.begin(); 

  filter.begin(100); 

  delay(2000);      

  FastLED.addLeds<APA102,11,13,BGR,DATA_RATE_MHZ(1)>(leds, NUM_LEDS);  

  pinMode(7, OUTPUT); 

  digitalWrite(7, HIGH);  // enable access to LEDs 

   

void loop() { 

  float ax, ay, az; 

  float gx, gy, gz; 

  float mx, my, mz; 

  float roll, pitch, heading; 

   

  if (imu.available()) { 

    // Read the motion sensors 

    imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz); 

   

    // Update the SensorFusion filter 

    filter.update(gx, gy, gz, ax, ay, az, mx, my, mz); 

   

    // print the heading, pitch and roll 

    roll = filter.getRoll(); 

    pitch = filter.getPitch(); 

    heading = filter.getYaw(); 

    Serial.print("Orientation: "); 

    Serial.print(heading); 

    Serial.print(" "); 

    Serial.print(pitch); 

    Serial.print(" "); 

    Serial.println(roll); 

    a=abs(roll/3); 

    Serial.print(" "); 

     

    acc_rms=sqrt(ax*ax+ay*ay+az*az)/3

    Serial.println(acc_rms); 

     

    //flash red if a violent shake event is detected 

     

    if(acc_rms==1

    { 

       for(int n = 0; n < NUM_LEDS; n++)  

       { 

           leds[n] = CRGB::Red; 

           FastLED.show(); 

           delay(8); 

           leds[n] = CRGB::Black; 

      } 

    } 

     

    // Move a single white led as per rotation  

   for(int n = 0; n < NUM_LEDS; n++)  

    { 

       if(a==n) 

       { 

          leds[n] = CRGB::White; 

          FastLED.show(); 

          delay(8); 

        } 

       else 

        { 

           leds[n] = CRGB::Black; 

        } 

    } 

  } 

}

PJRC Store

Sample Code:

  1. // Full orientation sensing using NXP's advanced sensor fusion algorithm. 
  2. // 
  3. // You *must* perform a magnetic calibration before this code will work. 
  4. // 
  5. // To view this data, use the Arduino Serial Monitor to watch the 
  6. // scrolling angles, or run the OrientationVisualiser example in Processing. 
  7.  
  8.  
  9. #include <NXPMotionSense.h> 
  10. #include <Wire.h> 
  11. #include <EEPROM.h> 
  12. #include <FastLED.h> 
  13.  
  14.  
  15. #define NUM_LEDS 60 
  16. CRGB leds[NUM_LEDS]; 
  17.  
  18.  
  19. NXPMotionSense imu; 
  20. NXPSensorFusion filter; 
  21. int a; 
  22. int acc_rms; 
  23. void setup() { 
  24.   Serial.begin(9600); 
  25.   imu.begin(); 
  26.   filter.begin(100); 
  27.   delay(2000);      
  28.   FastLED.addLeds<APA102,11,13,BGR,DATA_RATE_MHZ(1)>(leds, NUM_LEDS);  
  29.   pinMode(7, OUTPUT); 
  30.   digitalWrite(7, HIGH);  // enable access to LEDs 
  31.  
  32.  
  33. void loop() { 
  34.   float ax, ay, az; 
  35.   float gx, gy, gz; 
  36.   float mx, my, mz; 
  37.   float roll, pitch, heading; 
  38.  
  39.  
  40.   if (imu.available()) { 
  41.     // Read the motion sensors 
  42.     imu.readMotionSensor(ax, ay, az, gx, gy, gz, mx, my, mz); 
  43.    
  44.     // Update the SensorFusion filter 
  45.     filter.update(gx, gy, gz, ax, ay, az, mx, my, mz); 
  46.  
  47.  
  48.     // print the heading, pitch and roll 
  49.     roll = filter.getRoll(); 
  50.     pitch = filter.getPitch(); 
  51.     heading = filter.getYaw(); 
  52.     Serial.print("Orientation: "); 
  53.     Serial.print(heading); 
  54.     Serial.print(" "); 
  55.      Serial.print(pitch); 
  56.     Serial.print(" "); 
  57.     Serial.println(roll); 
  58.     a=abs(roll/3); 
  59.     Serial.print(" "); 
  60.      
  61.     acc_rms=sqrt(ax*ax+ay*ay+az*az)/3
  62.     Serial.println(acc_rms); 
  63.      
  64.     //flash red if a violent shake event is detected 
  65.      
  66.     if(acc_rms==1
  67.     { 
  68.        for(int n = 0; n < NUM_LEDS; n++)  
  69.        { 
  70.            leds[n] = CRGB::Red; 
  71.            FastLED.show(); 
  72.            delay(8); 
  73.            leds[n] = CRGB::Black; 
  74.       } 
  75.     } 
  76.      
  77.     // Move a single white led as per rotation  
  78.    for(int n = 0; n < NUM_LEDS; n++)  
  79.     { 
  80.        if(a==n) 
  81.        { 
  82.           leds[n] = CRGB::White; 
  83.           FastLED.show(); 
  84.           delay(8); 
  85.         } 
  86.        else 
  87.         { 
  88.            leds[n] = CRGB::Black; 
  89.         } 
  90.     } 
  91.  
  92.  
  93.   } 
  94. }
Labels (1)
Attachments
No ratings
Version history
Last update:
‎09-10-2020 01:37 AM
Updated by:
NXP Employee