Sunday, December 18, 2016

Auto light switch for bathroom using laser and IC4017

Many people forgets the bathroom and toilet lamps in ON state, absolutely this causes increasing electric bill and even decrease lamps lifespan. This circuit is a simple way to turning ON and OFF the bathroom or toilet lamp automatically without using microcontroller.
The circuit based on the counter IC4017 and laser. when a person go to bathroom his body cut the laser ray that is focused on the LDR in another side of the door frame, connecting and disconnecting the laser ray changed the LDR electric resistance and giving a positive signal to pin14 of the IC4017 through transistor 2N2222, since pin4 jumped to reset pin (pin15) so the output selector will be changed between pin3 and pin2. Pin3 run the transistor to running the relay.
Two LEDs showing ON state and OFF state. 330 ohm resistor used to LEDs protection by giving 15mA current to them.
You can use any other NPN transistor rather than 2N2222 such as BC547, C9013, 2N5551, etc. 
This circuit is suitable for light switching for any place that used by one person such as toilet and bathroom, you can't use it for the room because when second person coming  inside the room the lamp will be turns OFF.

Part list:
IC4017
Transistor 2N2222
Laser 5mW
Relay 5v 
LEDs
LDR
Resistor 1K
Resistor 200K
Resistor 2.2K
Resistor 330R
Capacitor 10nF
Diode 1N4007


Auto light switch for bathroom using laser and IC4017

Auto light switch for bathroom using laser and IC4017

In following video you can watch how the circuit works:


Saturday, November 26, 2016

220V Auto room light switch using Arduino and Lazer (Visitor counter)

Many peoples forgets the Room lamps in running state when nobody in the room, this causes increasing electric bill or battery energy losing in solar home.
This Arduino project is a visitor counter that turns OFF the lamp when nobody in the room automatically, it also can used for lamps of bathroom, toilet, kitchen, etc.
Visitor counter can makes by using different types of sensors, such as IR ray, Ultrasonic, Avoidance sensor, Laser ray, etc.
Here i used Laser because the laser has long distance range, Avoidance sensor is very easy to use but its distance rang is lower than 30cm.
You can make this project with LCD display for showing the numbers of people in the room but as you can see in the video i don't used display because its not important for me, any way the code is same with or without display.
This project help to power consumption optimizing. 

Parts list:
Arduino board 
1 Channel Relay module
Laser diode(2 pcs)
Light sensor modules(2 pcs)
Adapter 5v 200mA
If you want to using display, need :
16X2 LCD Display
Resistor 10K
Resistor 220 ohm

220V Auto room light switch using Arduino and Lazer (Visitor counter)


220V Auto room light switch using Arduino and Lazer (Visitor counter)

220V Auto room light switch using Arduino and Lazer (Visitor counter)

Manual OFF switch used when you are in the room but want to turning OFF the lamp for sleep.

220V Auto room light switch using Arduino and Lazer (Visitor counter)


I used 1000uF 16v capacitor for power line to protect the arduino board from sudden voltage raising but its not necessary.

220V Auto room light switch using Arduino and Lazer (Visitor counter)

220V Auto room light switch using Arduino and Lazer (Visitor counter)



There are some important notes for making this project: 

1-Put the laser diode in the door frame before LDRs to determine the LDRs suitable position and to making sure the laser beam and LDRs are in same straight line. 

2-The laser diodes must set in suitable height to become suitable for all peoples with different long. also you have pay attention to door handle position, when the door is closed, handle maybe cuts the laser beam so put the laser beam above the handle.

3-The laser is harmful for eyes when its directly toward your eyes. 

4-One problem will happen for ONLY FIRST TIME USING this project. That problem is:
When you are in the room and turns this project ON for first time the light will be OFF because the Arduino count zero people come in the room(nobody) when you try to getting out the room the arduino turns ON the light because it count -1 people in the room. So in first time please try to get out the room without cutting the laser beam.
I'm trying solve this problem in the code.  



Code:

#include<LiquidCrystal.h>
LiquidCrystal lcd(0, 1, 3, 4, 5, 6);
#define in 11
#define out 12
#define relay 13
int count=0;
void IN()
{
    count++;
    lcd.clear();
    lcd.print("Person In Room:");
    lcd.setCursor(0,1);
    lcd.print(count);
    delay(1000);
}
void OUT()
{
  count--;
    lcd.clear();
    lcd.print("Person In Room:");
    lcd.setCursor(0,1);
    lcd.print(count);
    delay(1000);
}
void setup()
{
  lcd.begin(16,2);
  lcd.print("Visitor Counter");
  delay(2000);
  pinMode(in, INPUT);
  pinMode(out, INPUT);
  pinMode(relay, OUTPUT);
  lcd.clear();
  lcd.print("Person In Room:");
  lcd.setCursor(0,1);
  lcd.print(count);
}
void loop()

 
  if(digitalRead(in))
  IN();
  if(digitalRead(out))
  OUT();
 
  if(count<=0)
  {
    lcd.clear();
    digitalWrite(relay, LOW);
    lcd.clear();
    lcd.print("Nobody In Room");
    lcd.setCursor(0,1);
    lcd.print("Light Is Off");
    delay(200);
  }
 
  else
    digitalWrite(relay, HIGH);
 
}

Wednesday, November 23, 2016

AC 220V Frequency counter using arduino

In this project i used Arduino and some other electronic components for AC mains frequency measurement.
Since Frequency is equal to: 1 divided by time period, so in first we should measure the time period. Time Period is the time of one full wave in AC voltage, means positive half wave+negative half wave.
Here i used optocoupler for detecting the frequency of AC voltage. 47K resistor decrease the current to about 5mA for running the optocoupler and one diode for half wave rectification  So the arduino here calculate the ON time and OFF time of optocoupler that connected to Pin 13 in arduino board, then divided 1 by (ON+OFF) Time for give the frequency. 
Since in arduino code the time always must insert as millisecond so we devide 1000 by ON+OFF Time for give the frequency.
The circuit 100% insulated from mains voltage and can not be harmful for your arduino board.
You can use any other available optocoupler rather than 817B. 

AC 220V Frequency counter using arduino

Parts list: 
Arduino board
LCD display 16x2
Resistor 10K
Resistor 220 ohm
Resistor 47K / 1W
Diode 1N4007
Potentiometer 10K
Optocoupler 817B or any optocoupler  

NOTE: Don't touch the circuit when it connected to mains voltage.
 
AC 220V Frequency counter using arduino

AC 220V Frequency counter using arduino



Code:

 #include <LiquidCrystal.h>
int input=13;

int high_time;
int low_time;
float time_period;
float freq;
float frequency;
LiquidCrystal lcd(0, 1, 3, 4, 5, 6);
void setup()
{
pinMode(input,INPUT);
lcd.begin(16, 2);
}
void loop()
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Frequency Meter");

high_time=pulseIn(input,HIGH);
low_time=pulseIn(input,LOW);


time_period=high_time+low_time;
time_period=time_period/1000;
frequency=1000/time_period;
lcd.setCursor(0,1);
lcd.print(frequency);
lcd.print(" Hz");
delay(500);
}

Tuesday, August 9, 2016

Simple 220v emergency LED light

This circuit is an emergency lamp that charge the battery by 220v electric line and when the power cut, run the LED lamp automatically.
The battery used in this circuit is a 3.7v Li-ion battery 2000mAH. charging current in this circuit is about 50mA, this current is good for slow charging since this circuit is an emergency lamp so it leaves under charging for a long time to charge the battery so high charging current maybe decrease the battery life.
The circuit is simple as possible and very helpful. 
You can use any other PNP transistor rather than S9012.

Parts list:
Transistor S9012
Li-ion 3.7v battery 1000 to 3000mAH(18650)
Resistor 270 ohm 2W
Resistor 1K
Resistor 5 ohm 2W
Capacitor 820nF 400v
Capacitor 470uF 16v
Diode bridge 1A or 4 x 1N4007
Zener diode 4.8v 1W
Diode 1N4007
White LED(24 pcs or more)


Simple 220v emergency  LED light

Simple 220v emergency  LED light







Monday, July 25, 2016

Fridge door alarm circuit with delay time

New fridge models contain an alarm to notice door leaves open, it prevent energy losing.
This circuit is a simple fridge door alarm that active when the fridges door leaves open for 15 seconds, this delay time depend on 10uF capacitor so you can increase this delay time by increasing the capacitor value.
Alarm sound frequency depend on second capacitor value.
The circuit run with 9v battery and draw 40mA when the alarm is active and lower than 10mA when it is in standby state. Its better to use a rechargeable 9v battery.

Parts list:
IC555 (2pcs)
Buzzer
LDR
Resistor 1M
Resistor 1.5M
Resistor 100K
Capacitor 10uF
Capacitor 220nF
Battery 9v

Fridge door alarm circuit with delay time

Fridge door alarm circuit with delay time

Friday, July 22, 2016

1.5V Electric fly zapper circuit

This circuit is an electric zapper that can convert 1.5v to very high voltage, so it can used as a fly killer. you have to connect two thin metal grid to the output exactly look like to commercial fly zapper. output voltage can reach to more than 2000v.
You can use almost any other PNP transistor rather than S8550 and any other NPN transistor rather than S9013.
The circuit run with 1.5v and consume 40mA to 100mA.

Parts list:
Transistor S9013
Transistor S8550
Resistor 30K
Capacitor 100nF
Capacitor 2uF 400v (8pcs)
Diode 1N5408 (8pcs)
Transformer 6v
Battery 1.5v 
Two thin metal grid



1.5V Electric fly zapper circuit1.5V Electric fly zapper circuit


Tuesday, July 12, 2016

220v AC timer using IC 555

This is a very useful timer that can run 110/220v AC load up to 10A.
This circuit give 5 time periods from 1 minute to 60 minutes, you have to select the time by time selector switch then press START to activating the relay for running the AC load and turning OFF the load after selected time automatically. 
Maximum time period in this timer is 60 minutes but if you need to higher period so you have to increase the value of 470uF capacitor or 4M resistor to higher value. 
If you need this timer for DC loads so can use second circuit diagram.

Parts list:
IC 555
Transistor 2N5551
Relay 12v
Red LED
Green LED
Push switch 
Selector switch
Diode 1N4007
Bridge diode 1A
Zener diode 12v 1W
Capacitor 470nF 400v
Capacitor 220uF 16v
Capacitor 100nF
Capacitor 470uF 16v
Resistor 270 ohm 2W
Resistor 30K
Resistor 1K(3pcs)
Resistor 100K
Resistor 500K
Resistor 1.5M
Resistor 2M
Resistor 4M

220v AC timer using IC 555





220v AC timer using IC 555

220v AC timer using IC 555 220v AC timer using IC 555