HomeMadeGarbage
Published

voice-activated Patrol Lamp

This is voice-activated Patrol Lamp. It have mic and sense voice. While sensing the voice, the lamp operate.

IntermediateFull instructions provided2 hours1,398

Things used in this project

Hardware components

Adafruit Trinket 3.3V
×1
DRV8830
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
LA4-466FB
×1
mic module
×1
SparkFun Polymer Lithium Ion Battery - 110mAh
×1
Adafruit LiIon/LiPoly Backpack Add-On
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Block Diagram

Code

patLamp_01.ino

Arduino
#include <Wire.h>
//#include "I2Cdev.h"
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

const int DRV8830 = 0x64;
//const int DRV8830 = 0x60;

const int analogInPin = 2;  
int sensorValue = 0;

#define PIN            1
#define NUMPIXELS      1
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
  Wire.begin();
  //Serial.begin(9600);

  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif

  pixels.begin();
}

//ref http://makers-with-myson.blog.so-net.ne.jp/2014-05-15
void writeMotorResister(byte vset, byte data1){
  int vdata = vset << 2 | data1;
  Wire.beginTransmission(DRV8830);
  Wire.write(0x00);
  Wire.write(vdata);
  Wire.endTransmission(true);
}

void loop() {
  sensorValue = analogRead(analogInPin);
  //Serial.println(sensorValue);

  if(sensorValue > 520 || sensorValue < 455){
    //LED ON (red)
    pixels.setPixelColor(0, pixels.Color(255,0,0));
    pixels.show();
    //Motor ON
     writeMotorResister(0x20, 0x01);
  }else{
    //LED OFF
    pixels.clear();
    pixels.show();
    //Motor OFF
    writeMotorResister(0x00, 0x00);
  }

  delay(50);
}

Credits

HomeMadeGarbage

HomeMadeGarbage

56 projects • 283 followers
We are family. hobby is D.I.Y!!

Comments