Author Archives: steve
Blurry face
Bogus UltraSonic Retina Scanner
/* YourDuino SKETCH UltraSonic Serial 1.0
Runs HC-04 and hopefully SRF-06 Ultrasonic Modules
Uses: Ultrasonic Library (Copy to Arduino Library folder)
http://iteadstudio.com/store/images/produce/Sensor/HCSR04/Ultrasonic.rar
terry@yourduino.com
The little red comes on with motion trigger
big red flashes
big red flash is a function
green comes on just after.
This is a good version.
*/
/*-----( Import needed libraries )-----*/
#include
#include "Ultrasonic.h"
/*-----( Declare Constants and Pin Numbers )-----*/
#define TRIG_PIN 12
#define ECHO_PIN 13
#define LILRED_PIN 10
#define BIGRED_PIN 9
#define BIGGRN_PIN 8
#define TRK3_PIN 3
#define TRK2_PIN 2
/* -----( Declare objects )-----*/
MP3Trigger trigger;
Ultrasonic OurModule(TRIG_PIN, ECHO_PIN);
/*-----( Declare Variables )-----*/
void setup() /****** SETUP: RUNS ONCE ******/
{
Serial.begin(9600);
Serial.println("UltraSonic Distance Measurement");
Serial.println("YourDuino.com terry@yourduino.com");
// pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
digitalWrite(TRK3_PIN, HIGH); // High is off?
digitalWrite(TRK2_PIN, HIGH); // High is off?
// Start serial communication with the trigger (over Serial)
// trigger.setup(&Serial);
// Serial.begin( MP3Trigger::serialRate() );
// trigger.setLooping(false,1);
// trigger.setLooping(false,2);
// trigger.setLooping(false,3);
//end
}//--(end setup )---
void checkRetina() {
digitalWrite(LILRED_PIN, HIGH);
for(int i=0;i<=15;i++){
digitalWrite(BIGGRN_PIN, LOW);
digitalWrite(BIGRED_PIN, LOW);
delay (random(200));
digitalWrite (BIGRED_PIN, HIGH);
delay (random(100));
}
digitalWrite(LILRED_PIN, LOW);
}
void loop() /****** LOOP: RUNS CONSTANTLY ******/
{
Serial.print(OurModule. Ranging(CM));
Serial.print("cm ");
delay(100); //Let echos from room dissipate
Serial.print(OurModule.Ranging(INC));
Serial.println("inches");
if (OurModule.Ranging(INC) <= 3){
checkRetina();
digitalWrite(BIGRED_PIN, LOW);
delay(500);
digitalWrite(BIGGRN_PIN, HIGH); // Turn on green light
digitalWrite(TRK2_PIN, LOW); // Triggers the track
delay(100);
digitalWrite(TRK2_PIN, HIGH); // Turn off the trigger
delay(5000); // Light stays on for X seconds
digitalWrite(BIGGRN_PIN, LOW); // Turn off green light
delay(500);
} else {
// digitalWrite(BUZZER_PIN, LOW);
digitalWrite(LILRED_PIN, LOW);
digitalWrite(BIGRED_PIN, HIGH);
}
}//--(end main loop )---
/*-----( Declare User-written Functions )-----*/
//*********( THE END )***********