WebTechKitchen; Your Web Technology Kitchen, contact us to create, or maintain your websites and other digital properties.

My new Ardruino Nano cubicle alarm

Submitted by barnettech on Thu, 08/28/2014 - 10:19

http://youtu.be/8n-leJtKLUI

I just made this Ardruino Nano cubicle alarm.  If anybody is within a few feet of your work cubicle, including behind me, the led will turn red.  

I used the HC-SR04 ultra-sonic sensor: 1.)  5V on Arduino to VCC of HC-SR04 2.)  Dig pin 12 on Arduino to Trig of HC-SR04 3.)  Dig pin 13 on Arduino to Echo of HC-SR04 4.)  GND on Arduino to GND of HC-SR04   Here's my sketch:    
#include 
Ultrasonic ultrasonic(12,13);
int ledPin = 11;
long int distanceInches;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}
void loop()
{
  Serial.print(ultrasonic.Ranging(INC));
  Serial.println("in");
  distanceInches = ultrasonic.Ranging(INC);
  if (distanceInches < 200) {
    digitalWrite(ledPin, HIGH);
  }
  else {
    digitalWrite(ledPin, LOW);
  }  
  delay(100);
}

Next I want to get the HC-SR04 Sonic Sensor working with Rasberri Pi https://www.modmypi.com/blog/hc-sr04-ultrasonic-range-sensor-on-the-ras…