Andre Bunker
Published

Summer Bridge AIB

I am a CNM student who has participated in the STEM Core summer program. This is my project while in the course.

BeginnerShowcase (no instructions)13
Summer Bridge AIB

Things used in this project

Hardware components

Argon
Particle Argon
×1
Base Shield V2
Seeed Studio Base Shield V2
×1
Grove - Light Sensor
Seeed Studio Grove - Light Sensor
×1
Grove - 6-Axis Accelerometer&Gyroscope
Seeed Studio Grove - 6-Axis Accelerometer&Gyroscope
×1
Grove - CO2 & Temperature & Humidity Sensor (SCD30)
Seeed Studio Grove - CO2 & Temperature & Humidity Sensor (SCD30)
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1

Software apps and online services

VS Code
Microsoft VS Code

Story

Read more

Schematics

Circuit Breadboard

Circuit Schematic

Code

Motion

C/C++
/*
 * Project Motion
 * Description: Learn to use accelerometer
 * Author: 
 * Date:
 */

#include <ADXL345.h>

int x, y, z; 
float ax, ay, az, pitch, roll; 


ADXL345 adxl; 

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

void setup() {
    Serial.begin(9600);
    adxl.powerOn();
}

void loop() {
    //read the accelerometer values and store them in variables  x,y,z    
    adxl.readXYZ(&x, &y, &z); //tell it to put data into x,y,z from reality
    Serial.printf("values of X = %i, Y = %i, Z = %i\n",x,y,z); //print along the usb cable

    // Get acceleration in g's
    double xyz[3]; //array xyz; acceleration of xyz into those variables
    adxl.getAcceleration(xyz);
    ax = xyz[0];
    ay = xyz[1];
    az = xyz[2];
    pitch = asin(ax)*(180/(M_PI));
    roll = atan2(ay,az)*(360/(2*M_PI)); 
    Serial.printf("values of X = %0.2f, Y = %0.2f, Z = %0.2f, pitch = %0.2f, roll = %0.2f\n",ax,ay,az,pitch,roll);
    delay(500);

}

Neopixel

C/C++
/*
 * Project neo
 * Description:
 * Author:
 * Date:
 */

#include "neopixel.h"
#include "colors.h"
#include "math.h"

#define PIXEL_PIN A2
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel pixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int i, pixelNum, color; 
bool buttonState; //gives a variable that can be on or off 
float bright, t, freq; //brightness, time, frequency (occilation)

SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);

// setup() runs once, when the device is first turned on.
void setup() {
  // Put initialization like pinMode and begin functions here.
  pinMode(D10,INPUT); //we've got a button attached
  freq = 1/3.0; //interger divided by interger is integer (would actually equal zero)
  pixel.begin();
  pixel.setPixelColor(5,red);
  pixel.show();
  i = 0; 
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
  // The core of your code will likely live here.
  
  buttonState = digitalRead(D10); //whatever the button actually is, T(Pressed) or F(not Pressed)
  while(buttonState == true) {
    t = millis() / 1000.0;
    bright = 127.5 * sin(2 * M_PI * freq *t) + 127.5; //Trig equation 
    pixel.setBrightness(bright); 
    i++;
    pixelNum = i % 14;
    color = i % 6;
    pixel.setPixelColor(pixelNum,rainbow[color]);
    pixel.show();
    delay(25); 
    buttonState = digitalRead(D10);
}
}

Credits

Andre Bunker

Andre Bunker

1 project • 1 follower

Comments

Add projectSign up / Login