Asher Garcia
Published

Summer Bridge AEG

I am a student participating in CNM's Summer Bridge program. I learned how to code and applied it to building a board.

BeginnerFull instructions provided22
Summer Bridge AEG

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 - Temperature & Humidity Sensor
Seeed Studio Grove - Temperature & Humidity Sensor
×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

summerbridge_bb_CBVuLlCHQn.jpg

summerbridge_schem_bsNP9qwabd.jpg

Code

Motion

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

#include <ADXL345.h>
#include "math.h"

float aroll;
float apitch;
int x, y, z;
float ax, ay, az;
int pitch;
int 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); 
    Serial.printf("values of X = %i, Y = %i, Z = %i\n",x,y,z);

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

}

Neopixel

C/C++
/*
 * Project neo_ino
 * 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;
float bright, t, freq;


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);
  freq = 1/3;

  pixel.begin();
  pixel.setPixelColor(5,red);
  pixel.setPixelColor(6,orange);
  pixel.setPixelColor(7,yellow);
  pixel.setPixelColor(8,magenta);
  pixel.setPixelColor(9,green);
  pixel.setPixelColor(10,orange);


  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);
  while(buttonState == true) {
    t = millis() / 1000.0;
    bright = 127.5 * sin(2 * M_PI * freq * t) + 127.5;
    pixel.setBrightness(25);
    i++;
    pixelNum = i % 14;
    color = i % 6;
    pixel.setPixelColor(pixelNum,rainbow[color]);
    pixel.show();
     delay(10);
     buttonState = digitalRead(D10);
  }


 
}

Credits

Asher Garcia

Asher Garcia

1 project • 3 followers

Comments

Add projectSign up / Login