Showing posts with label led. Show all posts
Showing posts with label led. Show all posts

Friday, 4 April 2014

Dark/Light sensor using transistor

Automatic dark detector senses darkness. As the light level decreases and LDR meets the maximum threshold resistance, the circuit automatically switches on the LED D1. 
Dark light sensor

Dark sensor with variable resistor:
Dark light sensor

A dark detector can be made using a variable resistor. The sensitivity of the circuit can be adjusted with a variable resistor.
High resistance-> more darkness to switch on the LED.
Low resistance-> less darkness to switch on the LED.
Automatic Light detector using variable resistor
A light detector senses light. As the light level increases and LDR meets the lowest threshold resistance, the circuit automatically turns on the LED D1. We can adjust the sensitivity using the preset VR1-10K.
LESS RESISTANCE(VR1)-> LESS DARKNESS TO SWITCH OFF THE LED
HIGH RESISTANCE(VR1)-> MORE DARKNESS TO SWITCH OFF THE LED
Dark light sensor

Just swap the resistor and LDR to convert a dark sensor to a light sensor
Dark light sensor

Friday, 30 August 2013

Arduino PIR sensor

In this simple project, we’ll build a motion-sensing alarm using a PIR (passive infrared) sensor and an Arduino microcontroller. This is a great way to learn the basics of using digital input (from the sensor) and output (in this case, to a noisy buzzer) on your Arduino.

This project requires just a few parts, and because you're using a solderless breadboard and pre-cut jumper wires, you won't need any tools at all — except your computer and USB cable to connect the Arduino.
Connect digital input/output (I/O) pin 2 on the Arduino to row 1 on the breadboard.Connect the 5V pin on the Arduino to row 2 on the breadboard, and connect a nearby ground (Gnd) pin to row 3.Find the Gnd (–), Vcc (+), and Out pins on the PIR sensor.Plug the PIR sensor into the breadboard so that its (–) pin connects to the Gnd row, its (+) pin connects to 5V, and its Out pin connects to digital pin 2. connect a 10k resistor between PIR output pin and vcc.



Plug the LED's anode (the longer leg) into digital pin 13 on the Arduino.Plug the LED's cathode (the shorter leg, and/or the leg on the flattened side of the LED base) into the adjacent ground (Gnd) pin on the Arduino.Connect the buzzer's red wire to the Arduino's digital pin 10.Connect the buzzer's black wire to the Arduino's Gnd pin (there's a spare one on the Power block of pins).NOTE: These two wires can be reversed, as the polarity of the buzzer doesn't matter.

Code

int ledPin = 13;                // choose the pin for the LED
int inputPin = 2;               // choose the input pin (for PIR sensor)
int pirState = LOW;             // we start, assuming no motion detected
int val = 0;                    // variable for reading the pin status
int pinSpeaker = 10;           //Set up a speaker on a PWM pin (digital 9, 10, or 11)

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(pinSpeaker, OUTPUT);
  Serial.begin(9600);
}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    playTone(300, 160);
    delay(150);

    
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("Motion detected!");
      // We only want to print on the output change, not state
      pirState = HIGH;
    }
  } else {
      digitalWrite(ledPin, LOW); // turn LED OFF
      playTone(0, 0);
      delay(300);    
      if (pirState == HIGH){
      // we have just turned of
      Serial.println("Motion ended!");
      // We only want to print on the output change, not state
      pirState = LOW;
    }
  }
}
// duration in mSecs, frequency in hertz
void playTone(long duration, int freq) {
    duration *= 1000;
    int period = (1.0 / freq) * 1000000;
    long elapsed_time = 0;
    while (elapsed_time < duration) {
        digitalWrite(pinSpeaker,HIGH);
        delayMicroseconds(period / 2);
        digitalWrite(pinSpeaker, LOW);
        delayMicroseconds(period / 2);
        elapsed_time += (period);
    }
}

Upload the code to the arduino and test it.
Enjoy!!!!!!

Tuesday, 20 August 2013

Power Supply for Breadboard

Embedded systems require electric power to operate. Most of the components in them including the processors can operate at a wide range of voltages. For example, the operating voltage range for PIC16F688 is from 2 to 5.5 V. It means you can supply power from three AA size batteries (4.5 V) and it will work just fine as long as the battery voltage doesn’t fall below 2 V. But there are certain applications where you need a regulated constant voltage for safer operation of the embedded system. For instance, any application that uses analog-to-digital converters (ADCs). ADCs require a fixed reference voltage to provide accurate digital count for input analog signal. If the reference voltage is not stable, the ADC output is meaningless. So, today we are going to make a regulated +5V power source for our lab.
An LM7805 linear regulator IC is used for this purpose. It converts a DC input voltage of range 7-25 V to a stable +5 V. It requires just two external capacitors and is very easy to use, as shown below.
The input DC voltage for LM7805 could be obtained from a 9V DC wall adapter that can supply 1 Amp of load current. Actually, 12 to 24 V adapter will work too, but the LM7805 regulator dissipates an extreme amount of heat energy at higher input voltages and, therefore, requires a bulky heat sink. The wall adapter is chosen because it is cheap, easily available (you might already have got a spare one at home), and safe (the high voltage mains AC is isolated). You can solder this circuit on a general purpose prototyping board.

Radio Frequency(RF) Module

This example uses HT12E/D encoder-decoder pair for converting the parallel data to serial and back.



This encoder-decoder pair supports 4 bit parallel data.The circuit has two parts transmitter and receiver. In the transmitter part we are using HT12E for encoding data from parallel to serial. The serial output from the from the encoder is fed to the data IN of the RF transmitter. Four switches namely SW0,SW1,SW2,SW3 are used to input data to the decoder. These switches are pushbutton switches with active low states.(i.e.when you press it, the data input will be '0' and in the released state data input will be '1'. The default state is '1').

At the receiver section we are having RF receiver and HT12D decoder IC. The serial data from the receiver is fed into to serial input of the decoder. The parallel data is displayed with the help of LED's .

Another LED at the pin VT of the decoder shows whether your link is established or not. If it is ON then everything is OK. Instead if it is permanently OFF, then there is a link failure. You may refer the data sheet of the IC to know the  exact function of pin VT. After each successful transmission of a 4-bit data, VT pin goes to a low state for a while and will come back to high state. Thus during the transmission you may see the LED at pin VT blinking.

Troubleshooting:

If your circuit is not working, just remove the RF transmitter and receiver and make a wired connection from the serial data OUT of the HT12E encoder to the serial data IN of the HT12D decoder. Now check whether you could receive the data send from the encoder to decoder. If it is not working, you can conclude that problem is with the encoder/decoder pair. Either there will be some bugs in the circuit or your IC's might be damaged ones.

Thursday, 8 August 2013

Glow LED not Blow

I've noticed that some people are uncertain how to calculate series resistance for a LED or when using a group of LEDs are uncertain about wiring them in series or parallel. This walkthrough will try and explain how and why.
LEDs come in a wide range of colour, brightness and power ratings. Some of the latest highpower LEDs even require heatsinking. No matter what LED you want to use, they all have some basic properties in common that you need to know before using them in a circuit.
First of all, LEDs are a polarised electronic component. This means that power must be connected the right way or else damage will occur. For this reason there is always some indication on the caseing as to which lead is positive and which is negative.

Calculate the resistor value

To calculate the correct resistor value you need to know a few things about your LED.
1. what is it's forward voltage drop?
2. what is it's maximum continuous forward voltage.
This information should be supplied with you LEDs or can be found in the data sheet. I've attached the data sheet for a high intensity IR LED as an example of what to expect. It is worth becoming familiar with data sheets. You don't need to understand everything in them but you should be able to find basic information such as absolute maximum ratings and electrical characteristics. The second attachment covers a wide range of components but in the section on LEDs it gives you details on various LEDs such as forward voltage and max continuous current. It demonstrates that both values can vary widely depending on the LED.
Once you know the forward voltage drop and maximum current you can work out your circuit design and resistor values.
This is a basic power indication LED circuit. The formula for calculating the series resistor is:
R ohms = (Vsupply - VLED) / I where "I" is current in amps. For the circuit on the right, assume the supply voltage is 7.2V, the forward voltage of the diode is 2.1V and it's maximum forward current is 15mA.
R ohms = (7.2V - 2.1V) / 0.015A
R ohms = 5.1V / 0.015A
R ohms = 340 ohms
Since you can't get a 340 ohm resistor I would use a 390 ohm. The current would be less giving you a safety margin.
If you are driving a LED from a processor output as an indicator light then the same formula works except that your supply voltage is that of the processor (usually 5V) and your processor is limited on it maximum current output. Pic processors have a maximum limit of 25mA which is enough for most LEDs. Note that the forward voltage of the LED must be less than the supply voltage or else it wont light up.