Joyce
Published © GPL3+

PIR motion sensor with Seeed Studio XIAO Expansion Board

Here is the Seeed Studio XIAO Expansion Board and PIR motion control LED Ring.

BeginnerProtip263
PIR motion sensor with Seeed Studio XIAO Expansion Board

Things used in this project

Hardware components

Seeed Studio XIAO Expansion Board
Seeed Studio XIAO Expansion Board
Seeed Studio Grove -PIR Motion Sensor
×1
Grove - RGB LED Ring (20 - WS2813 Mini)
Seeed Studio Grove - RGB LED Ring (20 - WS2813 Mini)
Seeed Studio Seeeduino XIAO
×1
Seeed Studio XIAO nRF52840
Seeed Studio XIAO nRF52840
×1
Grove - PIR Motion Sensor
Seeed Studio Grove - PIR Motion Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code

Arduino
#include "Adafruit_NeoPixel.h"
#define PIR_MOTION_SENSOR A0
int ledstripPin = A5; //Set your RGB Ring Pin
int intnumber;
#define NUMPIXELS      48 // Set your # of the PIXELS (in my case I have 48 pixels in my ring)
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, ledstripPin, NEO_GRB + NEO_KHZ800);
 
int delayval = 1;
void setup() {
  Serial.begin(9600);
  pinMode(PIR_MOTION_SENSOR, INPUT);
 
  pixels.begin();
}

void loop() {

long sensorvalue;
long MeasureIn;

  if(digitalRead(PIR_MOTION_SENSOR)){  
     for(int i=0;i<NUMPIXELS;i++){
 
     pixels.setBrightness(255);// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(255,0,255)); 
 
    pixels.show(); // This sends the updated pixel color to the hardware.
 
    delay(delayval);
    Serial.println("1");
  }
  }
  else 
  {

 for(int i=0;i<NUMPIXELS;i++){
   pixels.setBrightness(0); // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,0,0)); 
  
    pixels.show(); // This sends the updated pixel color to the hardware.
 
    delay(delayval);
    Serial.println("2");
 }
  }

}

Credits

Joyce
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.