• Arduino

    Learn about Arduino and make various interesting projects using Arduino...

    Read More
  • 555 IC

    Learn about 555 IC and make various interesting projects using 555 IC...

    Read More
  • Basic Electronics

    Learn about Basic Electronics and various electronic components and their working...

    Read More

Arduino: Working with “Bouncy” Buttons

When was the last time you had to hold a button down to keep a light on?
Probably never. It makes more sense to be able to click the button once to turn it
on and to click the button again to turn it off. This way, you do not have to hold
the button down to keep the light on. Unfortunately, this is not quite as easy as
you might first guess. You cannot just look for the value of the switch to change
from low to high; you need to worry about a phenomenon called switch bouncing.
Buttons are mechanical devices that operate as a spring-damper system. In
other words, when you push a button down, the signal you read does not just
go from low to high, it bounces up and down between those two states for a
few milliseconds before it settles.


The button is physically pressed at the 25ms mark. You would expect the
button state to be immediately read as a high logic level as the graph on the left
shows. However, the button actually bounces up and down before settling, as
the graph on the right shows.

If you know that the switch is going to do this, it is relatively straightforward
to deal with it in software. Next, you write switch-debouncing software that
looks for a button state change, waits for the bouncing to finish, and then reads
the switch state again. This program logic can be expressed as follows:

1.  Store a previous button state and a current button state (initialized
to LOW).
2.  Read the current button state.
3.  If the current button state differs from the previous button state, wait 5ms
because the button must have changed state.
4.  After 5ms, reread the button state and use that as the current button state.
5.  If the previous button state was low, and the current button state is high,
toggle the LED state.
6.  Set the previous button state to the current button state.
7.  Return to step 2

Within the program flow (listed in the preceding steps) is a series of repeating steps that need to be applied to changing variable values. Because you’ll want to repeatedly debounce the switch value, it’s useful to define the steps for debouncing as a function that can be called each time. This function will accept the previous button state as an input and outputs the current debounced button
state. The following program accomplishes the preceding steps and switches the LED state every time the button is pressed.

Sketch:
const int LED=9; //The LED is connected to pin 9
const int BUTTON=2; //The Button is connected to pin 2
boolean lastButton = LOW; //Variable containing the previous
//button state
boolean currentButton = LOW; //Variable containing the current
//button state
boolean ledOn = false; //The present state of the LED (on/off)
void setup()
{
pinMode (LED, OUTPUT); //Set the LED pin as an output
pinMode (BUTTON, INPUT); //Set button as input (not required)
}
/*
* Debouncing Function
* Pass it the previous button state,
* and get back the current debounced button state.
*/
boolean debounce(boolean last)
{
boolean current = digitalRead(BUTTON); //Read the button state
if (last != current) //if it's different…
{
delay(5); //wait 5ms
current = digitalRead(BUTTON); //read it again
return current; //return the current value
}
void loop()
{
currentButton = debounce(lastButton); //read deboucned state
if (lastButton == LOW && currentButton == HIGH) //if it was pressed...
{
ledOn = !ledOn; //toggle the LED value
}
lastButton = currentButton; //reset button value
digitalWrite(LED, ledOn); //change the LED state
}

Making Traffic Lights using 555 IC

Here's a clever circuit using two 555's to produce a set of traffic lights for a model layout.  The red LED has an equal on-off period and when it is off, the first 555 delivers power to the second 555. This illuminates the Green LED and then the second 555 changes state to turn off the Green LED and turn on the Orange LED for a short period of time before the first 555 changes state to turn off the second 555 and turn on the red LED.
A supply voltage of 9v to 12v is needed because the second 555 receives a supply of about 2v less than rail.
This circuit also shows how to connect LEDs high and low to a 555 and also turn off the 555 by controlling the supply to pin 8. Connecting the LEDs high and low to pin 3 will not work and since pin 7 is in phase with pin 3, it can be used to advantage in this design.

Here is a further description of how the circuit works:

 Both 555's are wired as oscillators in astable mode and will oscillate ALL THE TIME when they are turned ON. But the second 555 is not turned on all the time! The first 555 turns on and the 100u is not charged. This makes output pin 3 HIGH and the red LED is not illuminated. However the output feeds the second 555 and it turns on.

  Output pin 3 of the second 555 turns on the green LED and the second 100u charges to 2/3 rail voltage and causes the 555 to change states. The green LED goes off and the orange LED turns on. The second 100u starts to discharge, but the first 100u is charging via a 100k and after the orange LED has been on for a short period of time, the first 555 changes state and pin 3 goes LOW.

This turns on the red LED and turns off the second 555.
The first 100u starts to discharge via the 100k and eventually it changes state to start the cycle again.

The secret of the timing is the long cycle-time of the first 555 due to the 100k and the short cycle due to the 47k on the second 555.

COMPONENTS USED :
1.Two 555 IC.
2.Two 100uF cap.
3.one 100K resistance.
4.one 47K resistance.
5.one 470ohm resistance.
6.Two 220ohm resistance.
7.one red LED.
8.one orange LED.
9.one green LED.
10.one 6-12V power Supply.


(NOTE - i didnt had a 47k resistances so i used a series of resistances to make 47k resistance, and i also used double LED's ,two green ,two red,two yellow. Just place 2nd LED in parallel with the LED in the circuit and you are done.!)





Uneven Clicks using 555 IC

This circuit produces two clicks then a short space before two more clicks etc. Changing the voltage on pin, 5 via the diode, adjusts the timing of the chip.
This circuit uses the 1N4148 diode to regulate the voltage on pin 5 of 555 IC to produce uneven click sound  effect.

COMPONENTS USED :
1.one 555 IC
2.one 1N4148 Diode
3.one 47K resistance
4.two 10uF Electrolytic capacitance
5.one 8ohm speaker
6.one 6-12V power supply


STEPS :
1.Place 555 IC on breadboard.
2.Connect pin 2 to pin 6.
3.Connect pin 4 to pin 8.
4.Connect pin 1 to ground.
5.Connect pin 8 toVCC.
6.Connect pin 2 with positive side of a 10uF cap,connect negative side to ground.
7.Connect a 47K resistance between pin 2 and pin 3.
8.Connect the 1N4148 diode between pin 5 and pin3.
9.Connect long leg of  another 10uf with pin3 .
10.Connect shorter leg of cap above with one terminal of speaker,connect another terminal of speaker to ground.
11.Turn on power supply and Enjoy..!



(NOTE - i didnt have a 47K resistance so i used a combination of resistances to make up 47K resistance )





Rail Road crossing Flashing LED using 555 IC

This circuit flashes two red LEDs for a model railway crossing.The circuit uses a 555 IC to flash the LED's alternatively to give effect of a rail-roard crossing lights.

COMPONENTS USED :

1.555 IC
2.two LED's (any color but recommended Red)
3.Two 470 ohm/ 220 ohm resistances
4.one 47K resistance
5.one 10uF Electrolytic Capacitance
6.one 6-12V supply


STEPS :

1.Place 555 IC on BreadBoard.
2.connect pin 2 to pin 6.
3.connect pin 4 to pin 8.
4.connect a 47K resistance between pin 2 and pin 3.
5.connect a 10uF cap between pin 2 and ground.
6.connect pin 1 to ground.
7.connect pin 8 to VCC.
8.connect a 470/220 ohm resistance between pin 3 and shorter leg of a LED,connect the longer led of that LED to VCC.
9.connect another 470/220 ohm resistance between pin 3 and longer led of 2nd LED , connect the shorter leg of that LED to ground.
10.Switch on Power supply and Enjoy.!


(NOTE : In pics below i have placed a series of resistances to make up 47K resistance,also instead of only 2 LED's  i used 4 . Just place  LED in parallel with LED's in your circuit and you are done.You can also place them in series but it will dim their intensity)




Best Android apps for Electronic and Electrical Engineers

1.Electrodroid

ElectroDroid is a simple and powerful collection of electronics tools and references.

                           

Download Electrodroid free

2.Everycircuit

EveryCircuit is not just an eye candy. Under the hood it packs custom-built simulation engine optimized for interactive mobile use, serious numerical methods, and realistic device models. In short, Ohm's law, Kirchhoff's current and voltage laws, nonlinear semiconductor device equations, and all the good stuff is there.
Growing library of components gives you freedom to design any analog or digital circuit from a simple voltage divider to transistor-level masterpiece.
Schematic editor features automatic wire routing, and minimalistic user interface. No nonsense, less tapping, more productivity.


3.Engineering Handbook Lite

This is an amazingly useful and handy app for every engineering student.  It provides all the concepts of engineering and formulae and can also help in length mathematical calculations.



4.Droid Tesla

is another free app for simulating electronic circuits. This SPICE simulation tool is quiet similar to the app “EveryCircuit” mentioned above in its functionality - means you can build and simulate a circuit. But they both (EveryCircuit and DroidTesla) differ in user interface and features provided.



5.Electronics Tooolkit

is another free app which is a collection of simple tools like resistor color code calculator, series and parallel calculator etc. Almost all those tools are available in ElectroDroid app too, except for a Power Triangle calculator. I have listed this app here as it is free (and I have spent some time to download and test this app in my Galaxy) and you guys can try out, if you have time.More than 10,000 users have tried this application.



6.AllDataSheet app

This app is free version of the Datasheet website Alldatasheet.com. This app is nothing more than a book mark to alldatasheet website’s mobile version. I dont recommend you to download this app as your purpose will be served by visiting Alldatasheet.com from your mobile browser (which will get automatically redirected to mobile version) 



7.Logic simulator

Logic Simulator is a powerful tool for simulating logic circuits and testing how different gates can be used in a circuit,
It offers a big workspace and a simple menu system. It is perfect for education on a mobile platform.
To connect nodes you simply click on an output and then click on an input to connect it to.




8.Electronics Calculator

Simple electronics tools & calculators for your DIY projects.
Tools:
- Resistor Color Code (4,5 &6 band)
- Capacitor Conversion Calculator & Table
- Capacitor Code Converter (code to values - vica versa)
- Resistor in Series & Parallel
- Capacitor in Series & Parallel







Make piano using 555 IC

This circuit produces a tone according to the button being pressed. Only 1 button can be pressed at a time, that's why it is called a monophonic organ. You can change the 1k resistors to produce a more-accurate scale.Each button has a different tone , Moreover you can alter resistances to get soundsof your choice.

COMPONENTS USED :

1.555IC
2.Six1K resistances.
3.one 10K resistance
4.one 10uF Electrolytic capacitor
5.one 100nF Ceramic Capacitor
6.one 8ohm speaker
7.Six Push buttons(Tick-Tack buttons)
8.one 6-12V supply

The circuit below shows the arrangement neede for 555 piano:



STEPS :

1.Place 555 IC on BreadBoard
2.Connect pin 1 to ground.
3.Connect pin 8 and pin 4.
4.Connect pin 6 and pin 2.
5.Connect 100nF between pin 2 and ground.
6.Connect 10uF cap to pin 3 with Longer leg towards pin3.
7.Connect Shorter leg of the Cap above to one side of speaker, connect other side of speaker to ground.
8.Connect pin 8 to VCC.
9.Connect a 1k resistance between pin 7 and VCC.
10.Then connect a 10K variable resistor between pin 7 and one end of Push button, connect other end of push button to pin 6.
11.Then repeat connection of other buttons and 1K resistances as Shown in above Diagram.







(NOTE - In the circuit below i added  a LED between +ve and -ve terminal of battery to indicate if the piano is on or off , it is useful in case you want to make this ckt on a PCB , LED will help in indicating if piano is on and it can be switched off when not in use to save battery. A Switch can also be placed b/w the VCC and the ckt to switch piano on and off)


Machine Gun Sound Using 555 IC

This Circuit using 555 IC produces sound similar to a machine gun.It uses a combination of resistances and capacitances along with 555 IC which produces machine gun sound.



Components used:
1.one 555 IC
2.one BC557 Transistor
3.one 8ohm Speaker
4.two 10nF Ceramic Capacitors
5.one 100uF Electrolytic Capacitor
6.two 10uf Electrolytic Capacitor
7.one 100K resistor
8.one 33K resistor
9.one 6-12v power supply

Steps :
 1.Place 555 IC on BreadBoard.
 2.Connect pin 1 to ground.
 3.Connect pin 2 with pin 6.
 4.Connect pin 4 with pin 8.
5.Connect 10nF cap with one leg connected to pin 5 and other to ground.(ceramic cap do not have +ve and -ve side)
6.Connect a 10nf cap with one leg to pin 2 and other leg to ground.
7.Connect a 33k resistor with one leg at pin 2 and other at pin 3.
8.Place a BC557 on breadboard and connect emitter to VCC.
9.Connect a 100uF cap with longer leg to emitter and shorter one to collector.
10.Connect a 100K resistor between base of transistor and ground.
11.Again Connect a 10uF between Base of transistor and one terminal of speaker,with longer leg of cap towards Base.
12.Connect a 10uf cap between pin 3 of 555  and the same terminal of step 11. above.
13.Connect other terminal of speaker to VCC.
14.Connect pin 8 to VCC.
15.Power on the circuit and you are done.

( NOTE -- i didn't have a 33K resistor so i tried by putting 3x 10K resistors , 2x 1K resistors in series equaling to 32K, And i have also placed a push button between VCC and the circuit in order to get more machine gun like effect manually)





Ticking Bomb Sound Circuit using 555 IC

This circuit sound just like a ticking bomb.It utilizes the astable mode of 555 IC and produces ticks that are similar to a time bomb ticking.

Components Used:

1.one 555 IC
2.two 10uF Electrolytic Capacitor
3.one 47K ohm resistor
4.one 6-12 V power supply
5.one 8Ohm speaker





STEPS :
1.Place 555 IC on BreadBoard.
2.Connect pin 1 to ground(-ve terminal of battery)
3.Connect pin 2 with pin 6.
4.Connect pin 4 with pin 8.
5.Connect pin 8 with VCC (+ve terminal of battery)
6.Connect 47K resistor with one leg at pin 2 and another at pin 3.
7.Connect 10uF cap with longer leg(+ve ) to pin 2 and shorter leg(-ve ) to ground.
8.Now connect another 10uF cap with longer leg to pin 3 and shorter leg to a terminal of speaker,
and connect another terminal of speaker to ground. 
9.leave pin 5,7 as there is no use of them in this circuit.
10.Turn on Power to circuit and Enjoy the effect.



(NOTE - I didnt have 47K so i tested the circuit by putting series resistances equal to 40K)

Simple Motor Control using Arduino

We are first going to simply control the speed of a DC motor, in one direction, using a power transistor, diode, and external power supply to power the motor and a potentiometer to control the speed. Any suitable NPN power transistor designed for high current loads can replace the TIP120 transistor. However, I would highly recommend you use a power Darlington-type transistor. Make sure you choose a transistor that can handle the voltage and current your motor will draw. It may be necessary to fit a heat sink to the transistor if it is pulling more than about an amp.

The external power supply can be a set of batteries or a “wall wart”-style external DC power supply. The power source must have enough voltage and current to drive the motor. The voltage must not exceed that required by the motor. For my testing purposes I used a DC power supply that provided 5V at 500mA. This was enough for the 5V DC motor I was using. If you use a power supply with voltage higher than the motor can take, you may damage it permanently.

























Connect It Up

First, make sure your Arduino is powered off by unplugging it from the USB cable. Now, take the required parts and connect them up as in Figure. It is essential for this project that you check and double check all of your connections are as they should be before supplying power to the circuit, as failure to do so may result in damage to your components or even your Arduino.



Enter the Code

Open up your Arduino IDE and type in the code

int potPin = 0; // Analog in 0 connected to the potentiometer
int transistorPin = 9; // PWM Pin 9 connected to the base of the transistor
int potValue = 0; // value returned from the potentiometer

void setup() {
// set the transistor pin as output:
pinMode(transistorPin, OUTPUT);
}
void loop() {
// read the potentiometer, convert it to 0 - 255:
potValue = analogRead(potPin) / 4;
// use that to control the transistor:
analogWrite(transistorPin, potValue);
}

Before uploading your code, disconnect the external power supply to the motor and ensure the potentiometer is turned fully counterclockwise. Now upload the code to the Arduino. Once the code is uploaded, connect the external power supply. You can now turn the potentiometer to control the speed of the motor.

Pulsating Lamp using Arduino

In this project we will alter the brightness of the LED, and make a pulsating lamp, using the analogWrite() function.

Parts Required

Table 3-3lists the parts required for Project 7. We simply use an LED and resistor.










Connect It Up

The circuit for this project is simply a green LED connecting, via a current-limiting resistor, between ground and Digital Pin 11.



Enter the Code

Open up your Arduino IDE and type in the code .

int ledPin = 11;
float sinVal;
int ledVal;
void setup()
 {
pinMode(ledPin, OUTPUT);
}
void loop() {
for (int x=0; x<180; x++)
 {
// convert degrees to radians then obtain sin value
sinVal = (sin(x*(3.1412/180)));
ledVal = int(sinVal*255);
analogWrite(ledPin, ledVal);
delay(25);
}
}

Verify and upload. You will now see your LED pulsate on and off steadily. Instead of a simple on/off state, we are now adjusting its brightness.

LED Chase Effect using Arduino

We are now going to use a string of LEDs (10 in total) to make an LED chase effect (see Table 3-1), similar to that used
on the car KITT in the KnightriderTV series or the Cylons in Battlestar Galactica.













Connect It Up

First, make sure your Arduino is powered off by unplugging it from the USB cable. Now take your breadboard, LEDs, resistors, and wires, and connect everything up as in Figure 3-1. Check your circuit thoroughly before connecting the power back up to the Arduino.



Enter the Code
Open up your Arduino IDE and type in the code .

 LED Chase Effect

byte ledPin[] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; // Create array for LED pins
int ledDelay = 65; // delay between changes
int direction = 1;
int currentLED = 0;
unsigned long changeTime;
void setup() {
for (int x=0; x<10; x++)
{
// set all pins to output
pinMode(ledPin[x], OUTPUT);
}
changeTime = millis();
}
void loop() {
if ((millis() - changeTime) > ledDelay)
{
// if it has been ledDelay ms since last change
changeLED();
changeTime = millis();
}
}
void changeLED()
 {
for (int x=0; x<10; x++)
{
// turn off all LED's
digitalWrite(ledPin[x], LOW);
}
digitalWrite(ledPin[currentLED], HIGH); // turn on the current LED
currentLED += direction; // increment by the direction value
// change direction if we reach the end
if (currentLED == 9) {direction = -1;}
if (currentLED == 0) {direction = 1;}
}

If you have done everything
correctly, you should now see the LEDs appear to move along the line, then bounce back to the start.

By changing the value of ledDelay, you can make the LED ping back and forth at different speeds. Try different
values to see what happens. You have to stop the program and manually change the value of ledDelay, then upload the amended code to see any changes.











Arduino cheatsheet!!


what is a Relay ?

A Relay is an electromagnetic device which is used to isolate two circuits electrically and connects them magnetically.
It is basically used in intrerfacing electronic circuit to an electric circuit. it means that a small DC voltage drives circuits working at large voltages like 230V AC (as in our homes).

A Relay consist of two parts
1. Input
2. Output

Input consist of a coil which gets energized when a voltage with appropriate magnitude is applied to it ( this voltage is known as Operating voltage). when the coil gets energized it generates a magnetic field which is responsible for the switching action of a relay.

Output consist of three contactors viz, NO,NC and COM.

NC- normally closed- In normal state or energized state the COM is connected to NC.
NO- normally open- In energized state COM gets connected to the NO.



When the DC voltage is applied at the input of relay the input coil gets energized by the applied voltage and generates magnetic field , this magnetic field switches over the COM contactor to NO
contactor. in this  way switching takes  place. and when the circuit gets denergized on the input side the COM is back to NC by a spring mechanism.

Types of relays-
1. DPDT
2.SPST
3.SPDT
4.DPST

DPDT- Double pole double throw - used to control two circuits , it has 6 pins. generally used in  robotics applications.

SPST- Single pole single throw - it is used for normal switching applications like ON/OFF.

SPDT- Single pole double throw- it is used for selecting "either" of the two power supplies. for eg. switching from 12V DC supply to 24V DC supply in a circuit.