(Created page with "=objective= In this tutorial, we will see how we could interface a simple switch to micrcontroller. Yes, it is indeed very simple, later in this tutorial we will do some logic...")
 
(objective)
Line 1: Line 1:
=objective=
+
{{Box|type=l_green_light|text=<br />
In this tutorial, we will see how we could interface a simple switch to micrcontroller. Yes, it is indeed very simple, later in this tutorial we will do some logical operations with LEDs and Switches.
+
=Objective=
 +
In this tutorial, we will see how we could interface a simple switch to micrcontroller. Yes, it is indeed very simple, later in this tutorial we will do some logical operations with LEDs and Switches.<br />
 +
<br />
 +
=Switch Basics=
 +
[[File:Switch Interface 8051.PNG|150x300px|right|Figure 1: A basic Switch]]
 +
If we directly connect a switch to one of the microcontroller port pins, the pin floats when the switch is open. Meaning, it is not at a fixed logic level 0v or 5v. Hence we pull the pin up through a resistor to 5v'''(LOGIC 1)''', as shown in the figure 1. Now, whenever the switch is pressed, it grounds'''(LOGIC 0)''' the port pin.<br />
 +
<br />
  
If we directly connect a switch to one of the microcontroller port pins, the pin floats when the switch is open. Meaning, it is not at a fixed logic level 0v or 5v. Hence we pull the pin up through a resistor to 5v'''(LOGIC 1)''', as shown in the figure 1. Now, whenever the switch is pressed, it grounds'''(LOGIC 0)''' the port pin.
+
Now we could go ahead and interface it to the microcontroller, but we would rather interface 8 switches and 8 LED's to two ports as shown in the schematic below.<br />
 +
<br />
 +
=Schematic=
 +
[[File:8051 SwitchesLEDs INTERFACE.PNG|650x400px|framed|Figure 2: Schematic Diagram]]
 +
As we can see the schematic has basic circuits for oscillator, reset and power connections for the micrcontroller. <br />
 +
*A DIP (dual in line package) Switch, array of 8 switches is connected to '''PORT3''' AND 8 LEDs to '''PORT2'''.<br />
 +
*Observe the '''RR1''' component, it is array of 8 resistors in a single pack(SIP). It is as good as connecting 8 pullup resistors as shown in figure 1. You could also use 8 discrete resistors as well.  
 +
 
 +
 
 +
 
 +
 
 +
 
 +
}}

Revision as of 18:33, 19 December 2013


Objective

In this tutorial, we will see how we could interface a simple switch to micrcontroller. Yes, it is indeed very simple, later in this tutorial we will do some logical operations with LEDs and Switches.

Switch Basics

Figure 1: A basic Switch

If we directly connect a switch to one of the microcontroller port pins, the pin floats when the switch is open. Meaning, it is not at a fixed logic level 0v or 5v. Hence we pull the pin up through a resistor to 5v(LOGIC 1), as shown in the figure 1. Now, whenever the switch is pressed, it grounds(LOGIC 0) the port pin.

Now we could go ahead and interface it to the microcontroller, but we would rather interface 8 switches and 8 LED's to two ports as shown in the schematic below.

Schematic

Figure 2: Schematic Diagram

As we can see the schematic has basic circuits for oscillator, reset and power connections for the micrcontroller.

  • A DIP (dual in line package) Switch, array of 8 switches is connected to PORT3 AND 8 LEDs to PORT2.
  • Observe the RR1 component, it is array of 8 resistors in a single pack(SIP). It is as good as connecting 8 pullup resistors as shown in figure 1. You could also use 8 discrete resistors as well.