Introduction: Chair Detector

Students in the elementary school are often tripped by the chairs and get injuries. We should make a machine for the teacher that could help the students to have the habit of moving their chairs under the desk before they leave the classroom. Teacher could turn off the device when the class started, so it won't make any noises. When the bell rings, the teacher will turn on the device by pressing the switcher that is connected to the Leonardo board. The ultrasonic sensor will detect whether there's chair between the desk and the floor. If the distance is more than 10cm than the device will have the red light on and the speaker will make some noise to remind the student. Otherwise, the green LED is on and the speaker won't make any noises.

By 5qn_

Step 1: Materials

Electronics:

  • 1x 3W 4Ω TR-066F Speaker
  • 3x 1/4W 82Ω resistor
  • 1x 1/4W 10kΩ precision resistor
  • 1x Ultrasonic sensor HC-SR04
  • 1x Green LED 5mm
  • 1x Red LED 5mm
  • 1x White LED 5mm
  • 1x Switcher 20mm*15mm
  • 13x Jumper wires
  • 13x Dupont wires 20p, double heads
  • 1x Arduino board (Arduino Leonardo)
  • 1x Breadboard
  • 1x USB cable

Hardware:

  • 1x 20cm* 30cm cardboard
  • 1x 13cm*23cm*7cm paper box

Tools:

Hot melting glue gun, Soldering gun, Utility knife, Ruler

Step 2: Box Cutting

Tools:

Utility knife, Ruler

Holes on the top of the box:

width*height

  • 2cm *1.5cm / switcher
  • 1.8cm*1.7cm / speaker
  • 4.5cm*1.5cm / ultrasonic sensor

Holes on the left of the box:

  • 1.5cm*0.7cm / USB cable
  • 1cm width *0.1cm hight x3 / LED light

Step 3: Box for Botton

Tools:

Utility knife, Ruler

Electronics:

Jumper wires

Steps:

3.1

Top cover

4cm*3cm and a 2cm*2cm hole

3.2

Left and the right part

3cm*3cm

3.3

Back and the front part

3cm*4cm

3.4

Button part

4cm*3cm

1cm from the left and right and dig a small hole for the wire

Step 4: Wiring

Electronics:

  • 1x 3W 4Ω TR-066F Speaker
  • 3x 1/4W 82Ω resistor
  • 1x 1/4W 10kΩ precision resistor
  • 1x Ultrasonic sensor HC-SR04
  • 1x Green LED 5mm
  • 1x Red LED 5mm
  • 1x White LED 5mm
  • 1x Switcher 20mm*15mm
  • 13x Jumper wires
  • 13x Dupont wires 20p, double heads
  • 1x Arduino board (Arduino Leonardo)
  • 1x Breadboard

PinMode:

const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor

const int echoPin = 6; // Echo Pin of Ultrasonic Sensor

const int speaker = 2; // DigitalPin of speaker

const int greenLight = 13; // Green LED Safe

const int redLight = 12; // Red LED Too close

const int activeLight = 11; // White LED Start sensor

const int button = 8; // Active button

Reminder:

Stick LED, speaker and ultrasonic with hot melting glue gun

Step 5: Arduino Codes

This part of the codes calculate the distance :

inches = microsecondsToInches(duration); // Microseconds to inches

cm = microsecondsToCentimeters(duration); // Microseconds to cm

long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2; // MicroSecond to inches

}

long microsecondsToCentimeters(long microseconds) {

return microseconds / 29 / 2; // MicroSecond to cm

}

This part of the codes print the distance on the monitor :

Serial.print(inches); // Print inches

Serial.print("in, ");

Serial.print(cm); // Printf cm

Serial.print("cm");

Serial.println();

This part of the codes had the main function :

buttonState = digitalRead(button); // The function will activate only when the switcher is on. If the switcher is off, the rest of the function won't work

if ( cm <= 10 ){ // Chair in
digitalWrite(13, HIGH); // Green on

digitalWrite(12, LOW); // Red off

}else{ // Chair out / dangerous

digitalWrite(13, LOW); // Green off

digitalWrite(12, HIGH); // Red on

tone( 2, 440.0, 100.0 ); // Speaker on

} delay(100);

}

Step 6: Adjusting Ultrasonic Sensor Distance

You can adjust the number in the if statement to other numbers. Click the tool and click the serial monitor, you can see the distance shown on the monitor.

Step 7: Video

Enjoy !!!