Naya Lee
Published

Smart helmet with turn signal

A project by a team of students from the Hebei University of Technology

IntermediateShowcase (no instructions)9 hours170
Smart helmet with turn signal

Things used in this project

Story

Read more

Code

SuperMaker123456.ino

Arduino
#include <Suli.h>
#include <acc_adxl345_Arduino.h>
#include <Wire.h>
#include "LIS3DHTR.h"
#include <Adafruit_NeoPixel.h>

Acc_Adxl345 acc;
LIS3DHTR<TwoWire> LIS;
#define WIRE Wire
Adafruit_NeoPixel pixels_2 = Adafruit_NeoPixel(250, 2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels_7 = Adafruit_NeoPixel(250, 7, NEO_GRB + NEO_KHZ800);
char itoaString[64];
Adafruit_NeoPixel pixels_8 = Adafruit_NeoPixel(250, 8, NEO_GRB + NEO_KHZ800);
float _E5_8A_A0_E9_80_9F_E5_BA_A6x;
float _E7_BA_A2_E5_A4_96;

float get3ada16Value(char xyz)
{
  float ax, ay, az;
  acc.get(&ax, &ay, &az);
  if(xyz == 0) return ax;
  if(xyz == 1) return ay;
  if(xyz == 2) return az;
}

void ledStripLightAll(const Adafruit_NeoPixel &pixels, const uint8_t &r,const uint8_t &g,const uint8_t &b)
{
    for(int i=0;i<250;i++){
        pixels.setPixelColor(i, pixels.Color(r,g,b));
        pixels.show();
    }
}

void setup(){
  acc.begin();
  pinMode(5, INPUT);
  pinMode(4, INPUT);
  LIS.begin(WIRE, 0x19);
  LIS.openTemp();
  delay(100);
  LIS.setOutputDataRate(LIS3DHTR_DATARATE_50HZ);
  LIS.setHighSolution(true);

  pixels_2.setBrightness(255);
  pixels_2.begin();

  pixels_7.setBrightness(255);
  pixels_7.begin();

  Serial.begin(9600);

  pinMode(A0, 2);
  pinMode(6, OUTPUT);
  pixels_8.setBrightness(255);
  pixels_8.begin();

}



void loop(){

  while(digitalRead(4) == false){
  }
  Serial.println("printf("+String(LIS.getAccelerationY())+","+String("null")+","+String("null")+","+String("null")+","+String("null")+")");
  if ((abs(LIS.getAccelerationY()) > 0.0001)) {
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(50);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(300);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(50);
    ledStripLightAll(pixels_2, 255, 23, 23);
    delay(800);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(200);
  } else {
    ledStripLightAll(pixels_7, 0, 0, 0);
    delay(10000);
    ledStripLightAll(pixels_2, 0, 0, 0);
    delay(10000);
  }

}

SuperMaker123468.ino

Arduino
#include <Adafruit_NeoPixel.h>
#include <Ultrasonic.h>

Adafruit_NeoPixel pixels_3 = Adafruit_NeoPixel(250, 3, NEO_GRB + NEO_KHZ800);
Ultrasonic ult5(5);
char itoaString[64];
float i;
float _E8_B6_85_E5_A3_B0_E6_B3_A2;

void setup(){
  pinMode(2, INPUT);
  pixels_3.setBrightness(255);
  pixels_3.begin();

}



void loop(){


}

Credits

Gu Jiacheng, Yang Boyun, Qin Jiayue, Jia Xiaodong

Posted by Naya Lee

Comments