Sunday, October 23, 2011

Circuit 11 - Larger Loads

Purpose:  To use a relay to switch currents between two LEDs

Equipment: 
  • Arduino x 1
  • Breadboard x 1
  • Arduino Holder x 1
  • CIRC-11 Breadboard Sheet x 1
  • Diode (1N4001) x 1
  • Transistor (P2N2222AG) x 1
  • Relay (SPDT) x 1
  • 10k Ohm Resistor x 1
  • 330 Ohm resistor x 2
  • LED x 2
  • Wire x  13

References:
Program Details:
This circuit is much more complicated than what we've used in the previous exercises. In this circuit a relay is introduced. A relay has a mechanical switch inside it which, when energized, trips and switches the current. In this circuit, we will use the switch to consecutively turn two LEDs on and off.

There is a diode in this circuit which is not really necessary but it is helpful. The purpose of it is to prevent energy loss as it makes sure that the electricity is flowing in one direction only. A transistor is used to switch the current into the relay. Without the transistor, we cannot control the Relay as it is connected to Pin2.

The programming in this is very simple, it is nearly the same as the very first program. There should be no difficulties in the programming part of this exercise. 


Time to Complete: 15 mins to assemble
                                 5 mins to code

Results: The first time we uploaded the program, nothing happened. This was because the transistor wasn't placed properly, so we flipped it around but only one light came on and it wasn't even blinking. We tried various things like switching LEDs, wires, resistors and even trying another group's Relay. We decided to rebuild it except this time we forget to add the diode. However when we ran it this time, the circuit worked. When we put the diode though, it stopped working. This was because we placed the diode in the wrong way so it didn't let any of the current pass through.

Picture:


Video: 


Tips: 
  • Place the transistor correctly, the flat side should be facing the relay and make sure it is not a temperature sensor.
  • Place the diode correctly, if it doesn't work then remove it from the circuit, it is not necessary
  • There are a lot of wires to connect, make sure you connect all of them

Further Work: I will change the delay time at a decreasing rate to make the LEDs blink faster and faster and then increase the delay to make them blink slower and slower. This will be similar to whats shown in the video. 

Program Modifications: The program is very similar to the one in the link below. The only change is the delay time which was switched from 1000 milliseconds to 500 milliseconds.

Program:

int ledPin =  2;                         // Relay is connected to pin2

void setup()  
{                
  pinMode(ledPin, OUTPUT); // ledPin is set as an output     
}

void loop()                     
{
  digitalWrite(ledPin, HIGH);    // The Led turns on
  delay(500);                           // Wait for 500 milliseconds
  digitalWrite(ledPin, LOW);   // The Led turns off
  delay(1000);                        // Wait for 500 milliseconds
}  

No comments:

Post a Comment