Welcome Machine
This project Use Led bulb and the Piezo to make a machine. The function of this machine is that when people can in your home the piezo will make the noise so that you can know it. Also, there will be a Hi that use the LED light bulb.
Prepare for Material
Part list:
- 1 x Arduino LEONARDO
- 13 LED light bulb
- 7 Resister
- 1 x Ultrasonic Distance sensor
- 1 x Pizeo
- plenty of wires
Programming the Arduino
int ardublockUltrasonicSensorCodeAutoGeneratedReturnCM(int trigPin, int echoPin)
{ long duration; pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); delayMicroseconds(20); digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); duration = duration / 59; if ((duration < 2) || (duration > 300)) return false; return duration; }
void setup() { digitalWrite( 6 , LOW );
pinMode( 5 , OUTPUT); pinMode( 8 , OUTPUT); pinMode( 9 , OUTPUT); pinMode( 10 , OUTPUT); pinMode( 11 , OUTPUT); pinMode( 12 , OUTPUT); pinMode( 13 , OUTPUT); }
void loop() { if (( ( ( ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) ) > ( 10.0 ) ) && ( ( ardublockUltrasonicSensorCodeAutoGeneratedReturnCM( 6 , 7 ) ) < ( 20.0 ) ) )) { digitalWrite( 5 , HIGH ); digitalWrite( 8 , HIGH ); digitalWrite( 9 , HIGH ); digitalWrite( 10 , HIGH ); digitalWrite( 11 , HIGH ); digitalWrite( 12 , HIGH ); digitalWrite( 13 , HIGH ); tone(3, 660.0, 1000.0); } else { digitalWrite( 5 , LOW ); digitalWrite( 8 , LOW ); digitalWrite( 9 , LOW ); digitalWrite( 10 , LOW ); digitalWrite( 11 , LOW ); digitalWrite( 12 , LOW ); digitalWrite( 13 , LOW ); noTone(3); } }