Introduction: One Touch Wardrobe

About: Lets learn together !!!
====================================================================

                                                                      UPDATE

                                                  THURSDAY, MARCH 01 , 2012
                                                     "FULL SOURCE CODE"
                                                                 at Step 6th

                                                    SUNDAY, MARCH 04, 2012
                                                              "NEW VIDEO"
                                                               at this page

====================================================================

this my first project with Arduino



I use Arduino Duemilanove With Motor Driver Shield
  • Microcontroller ATmega168
  • Operating Voltage 5V
  • Input Voltage (recommended) 7-12V
  • Input Voltage (limits) 6-20V
  • Digital I/O Pins 14 (of which 6 provide PWM output)
  • Analog Input Pins 6
  • DC Current per I/O Pin 40 mA
  • DC Current for 3.3V Pin 50 mA
  • Flash Memory 16 KB (ATmega168) or 32 KB (ATmega328) of which 2 KB used by bootloader
  • SRAM 1 KB (ATmega168) or 2 KB (ATmega328)
  • EEPROM 512 bytes (ATmega168) or 1 KB (ATmega328)
  • Clock Speed 16 MHz
Parts :
  • 2 x DC Motor
  • 5 x LED lamp ( I built it myself )
  • 4 x 7segment
  • 2 x DC Fan
  • 1 x Automatic Spray
  • Power supply 5volt Circuit
  • Motor Driver L298
  • Touch Switch IC555
  • Limit Switch
  • Accu 12V
  • Transformator 2A
  • Timing Belt
  • Alumunium
  • Mirror
  • Glass
  • Plywood


Step 1: The Controller

Arduino Motor Shield (L298N)

=================================================================================
Introduction
=================================================================================
This motor shield allows Arduino to drive two channel DC motors. It uses a L298N chip which deliveries output current up to 2A each channel. The speed control is achieved through conventional PWM which can be obtained from Arduino’s PWM output Pin 5 and 6. The enable/disable function of the motor control is signalled by Arduino Digital Pin 4 and 7.

The Motor shield can be powered directly from Arduino or from external power source. It is strongly encouraged to use external power supply to power the motor shield.

    Logic Control Voltage5V (From Arduino)
    Motor Driven Voltage4.8^35V (From Arduino or External Power Source)
    Logic supply current Iss≤36mA
    Motor Driven current Io≤2A
    Maximum power consumption25WT=75
    PWMPLL Speed control mode
    Control signal level:

        High2.3V≤Vin≤5V
        Low-0.3V≤Vin≤1.5V

==================================================================================
Pin Allocation
==================================================================================
"PWM Mode"
    Pin                                   Function
Digital 4                    Motor 2 Direction control
Digital 5                    Motor 2 PWM control
Digital 6                    Motor 1 PWM control
Digital 7                    Motor 1 Direction control

"PLL Mode"
    Pin                                     Function
Digital 4                    Motor 2 Enable control
Digital 5                    Motor 2 Direction control
Digital 6                    Motor 1 Direction control
Digital 7                    Motor 1 Enable control

==================================================================================
Sample Code
==================================================================================

//PWM Speed Control

//Arduino PWM Speed Control
int E1 = 6;  
int M1 = 7;
int E2 = 5;                        
int M2 = 4;                          

void setup()
{
    pinMode(M1, OUTPUT);  
    pinMode(M2, OUTPUT);
}

void loop()
{
  int value;
  for(value = 0 ; value <= 255; value+=5)
  {
    digitalWrite(M1,HIGH);  
    digitalWrite(M2, HIGH);      
    analogWrite(E1, value);   //PWM Speed Control
    analogWrite(E2, value);   //PWM Speed Control
    delay(30);
  } 
}

=======================================

//PLL Speed Control

//Arduino PLL Speed Control
int E1 = 7;  
int M1 = 6;
int E2 = 4;                        
int M2 = 5;                          

void setup()
{
    pinMode(M1, OUTPUT);  
    pinMode(M2, OUTPUT);
}

void loop()
{
  int value;
  for(value = 0 ; value <= 255; value+=5)
  {
    digitalWrite(M1,HIGH);  
    digitalWrite(M2, HIGH);      
    analogWrite(E1, value);   //PLL Speed Control
    analogWrite(E2, value);   //PLL Speed Control
    delay(30);
  } 
}

==================================================================================
Motor Driver L298
=================================================================================

I use for Fan

The Code :

void kipas()
{
    digitalWrite(kipasPin1, HIGH); 
    digitalWrite(kipasPin2, LOW); 
    digitalWrite(enablePin,HIGH);
    delay(1000);
}

void kipas_mati()
{
    digitalWrite(kipasPin1, LOW); 
    digitalWrite(kipasPin2, HIGH); 
    digitalWrite(enablePin,LOW);
    delay(1000);
}

=======================================================================================

Source :
http://www.dfrobot.com/wiki/index.php?title=Arduino_Motor_Shield_%28L298N%29_%28SKU:DRI0009%29

PDF :
http://droboticsonline.com/ebaydownloads/L298_Motor_Shield_Manual.pdf

Step 2: Touch Sensor

====================================================================================
Touch Switch
====================================================================================

There are a number of different types of TOUCH PLATES and different effects
can be created by the circuit.

1. Touch a set of pads and the project turns on.
When the finger is removed, the circuit turns off.
The finger can touch the pads for any length of time.
We also include the feature where the circuit extends the ON period,
so the circuit stays on for a length of time after the finger is removed.
This is shown in Circuits A.

2. Touch a set of pads fairly quickly and the project turns on.
Touch the pads again for a short period of time and the circuit turns off.
This is called the "Flip-Flop" effect. If the finger is kept on the pads,
the circuit will turn on-off-on-off at a rate of about once per second.
This is shown in Circuits B.

3. Touch one set of pads to turn the circuit on and another set of pads to turn the circuit off.
This is shown in Circuits C.

=====================================================================
Sorry ... I forget the source of this article..
=====================================================================

For this project I use Circuit C

Step 3: Limit Switch

I use three limit switches :
  • 1 for indicator door opened
  • 1 for indicator door closed
  • 1 for lamp

Step 4: LED Lamp

========================================================================
Calculating an LED resistor value
========================================================================
LED resistor circuit An LED must have a resistor connected in series to limit the current through the LED, otherwise it will burn out almost instantly.

The resistor value, R is given by:

R = (VS - VL) / I

VS = supply voltage
VL = LED voltage (usually 2V, but 4V for blue and white LEDs)
I = LED current (e.g. 10mA = 0.01A, or 20mA = 0.02A)
Make sure the LED current you choose is less than the maximum permitted and convert the current to amps (A) so the calculation will give the resistor value in ohms (ohm).
To convert mA to A divide the current in mA by 1000 because 1mA = 0.001A.

If the calculated value is not available choose the nearest standard resistor value which is greater, so that the current will be a little less than you chose. In fact you may wish to choose a greater resistor value to reduce the current (to increase battery life for example) but this will make the LED less bright.

For example
If the supply voltage VS = 9V, and you have a red LED (VL = 2V), requiring a current I = 20mA = 0.020A,
R = (9V - 2V) / 0.02A = 350ohm, so choose 390ohm (the nearest standard value which is greater).

Working out the LED resistor formula using Ohm's law
Ohm's law says that the resistance of the resistor, R = V/I, where:
  V = voltage across the resistor (= VS - VL in this case)
  I = the current through the resistor

So   R = (VS - VL) / I

===========================================================================
Connecting LEDs in series
===========================================================================
LEDs in series If you wish to have several LEDs on at the same time it may be possible to connect them in series. This prolongs battery life by lighting several LEDs with the same current as just one LED.

All the LEDs connected in series pass the same current so it is best if they are all the same type. The power supply must have sufficient voltage to provide about 2V for each LED (4V for blue and white) plus at least another 2V for the resistor. To work out a value for the resistor you must add up all the LED voltages and use this for VL.

Example calculations:
A red, a yellow and a green LED in series need a supply voltage of at least 3 × 2V + 2V = 8V, so a 9V battery would be ideal.
VL = 2V + 2V + 2V = 6V (the three LED voltages added up).
If the supply voltage VS is 9V and the current I must be 15mA = 0.015A,
Resistor R = (VS - VL) / I = (9 - 6) / 0.015 = 3 / 0.015 = 200ohm,
so choose R = 220ohm (the nearest standard value which is greater).

===========================================================================
Avoid connecting LEDs in parallel!
===========================================================================
Do not connect LEDs in parallel! Connecting several LEDs in parallel with just one resistor shared between them is generally not a good idea.

If the LEDs require slightly different voltages only the lowest voltage LED will light and it may be destroyed by the larger current flowing through it. Although identical LEDs can be successfully connected in parallel with one resistor this rarely offers any useful benefit because resistors are very cheap and the current used is the same as connecting the LEDs individually. If LEDs are in parallel each one should have its own resistor.

===========================================================================
SOURCE : http://www.kpsec.freeuk.com/components/led.htm
===========================================================================

Step 5: Power Supply

I use 2 way power :
1. Accu 12 volt
2. AC 220v

In Plan I want use Solar Cell for charge the accu

source : http://telinks.wordpress.com/2010/02/25/layout-pcb-catu-daya-dc-5v-dan-12v/

Step 6: Source Code

int E1 = 6; // enable motor 1 
int M1 = 7; // Motor 1
int E2 = 5; // enable motor 2                       
int M2 = 4; // motor 2                        
int sensor = 1; // input saklar sentuh
int limA = 8; // input limit switch pada saat pintu tertutup
int limB = 9; // input limit switch pada saat pintu terbuka
int kipasPin1 = 10;    // pin 2 on L293D
int kipasPin2 = 11;    // pin 7 on L293D
int enablePin = 12;    // pin 1 on L293D
int buttonState = 0; // pembaca perubahan high atau low
#define SW_NUTUP 8
#define SW_BUKA  9

void setup()
{
    pinMode(sensor, INPUT);
    pinMode(SW_NUTUP, INPUT);
    pinMode(SW_BUKA, INPUT);
    pinMode(M1, OUTPUT);  
    pinMode(M2, OUTPUT);
    pinMode(kipasPin1, OUTPUT);
    pinMode(kipasPin2, OUTPUT);
    pinMode(enablePin, OUTPUT);
}

void pintu_buka()
{
    digitalWrite(M1, HIGH);
    digitalWrite(E1, HIGH);
    digitalWrite(M2, LOW);
    digitalWrite(E2, HIGH);
    //delay (1000);
}

void pintu_tutup()

  int value;
  for(value = 0 ; value <= 255; value+=1)

    digitalWrite(M1, LOW);
    analogWrite(E1, 210); // motor kanan
    digitalWrite(M2, HIGH);
    analogWrite(E2, 210); // motor kiri
    delay (1);
}

void pintu_diam()
{
    digitalWrite(M1, LOW);
    digitalWrite(E1, LOW);
    digitalWrite(M2, LOW);
    digitalWrite(E2, LOW);
    delay (1);
}

void kipas()
{
    digitalWrite(kipasPin1, HIGH); 
    digitalWrite(kipasPin2, LOW); 
    digitalWrite(enablePin,HIGH);
    delay(1000);
}

void kipas_mati()
{
    digitalWrite(kipasPin1, LOW); 
    digitalWrite(kipasPin2, HIGH); 
    digitalWrite(enablePin,LOW);
    delay(1000);
}

void loop ()
{

  /* kondisi saat pintu tertutup dan sw di sentuh */
  if (digitalRead (sensor) && digitalRead (SW_NUTUP))
    for (;;)  {
      pintu_buka ();
      if (digitalRead (SW_BUKA)) {
        pintu_diam ();
        break;
      }
      else {
        kipas_mati();
      }
    }

  /* kondisi saat pintu terbuka lalu sw di sentuh */ 
  if (digitalRead (sensor) && digitalRead (SW_BUKA))
    for (;;)  {
      pintu_tutup ();
      if (digitalRead (SW_NUTUP)) {
        pintu_diam ();
        break;
        }
         else {
        kipas();
      }
    }

}

Step 7: Closing



So far from perfect ^_^ ...
I hope this make inspirations for you ...
Thanks !!!
Furniture Challenge

Participated in the
Furniture Challenge

Arduino Challenge

Participated in the
Arduino Challenge