Cruz Moreno
Published

Summer Bridge CAM

I am in the Summer Bridge program through CNM and I learned about IoT this week. Mr. Barashap is a great instructor and has lots to share.

BeginnerFull instructions provided13
Summer Bridge CAM

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

Circuit Schematic

Circuit BreadBoard

Code

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;
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.0;
pixel.begin();
pixel.setPixelColor(7,green);
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(bright);
    i++;
    pixelNum = i % 14;
    color = i % 6;
    pixel.setPixelColor(pixelNum,rainbow[color]);
    pixel.show();
    delay(20);
    buttonState = digitalRead(D10);
  }
  
}

Motion

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

#include <ADXL345.h>
#include "math.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); 
    //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];
    pitch = asin(ax)*(360/(2*M_PI));
    roll = atan2(ay,az)*(360/(2*M_PI));
    Serial.printf("values of X = %0.2f, Y = %0.2f, Z = %0.2, pitch = %0.2f, roll = %0.2f\n",ax,ay,az, pitch,roll);

    delay(500);

}

Credits

Cruz Moreno

Cruz Moreno

1 project • 1 follower

Comments

Add projectSign up / Login