0% found this document useful (0 votes)
8 views

Lab Task 05 (Button With LEDs)

This lab document outlines an experiment to toggle LEDs with button presses using a microcontroller. The objectives are to interface a button with a microcontroller, observe button operation, and control an LED. An AT89C51 microcontroller development board with buttons and LEDs is used along with Keil μVision IDE software. Students will write code in C language to toggle the LED state each time the button is pressed. The code will be compiled to a hex file and uploaded to the microcontroller to test the button-controlled LED toggling.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Lab Task 05 (Button With LEDs)

This lab document outlines an experiment to toggle LEDs with button presses using a microcontroller. The objectives are to interface a button with a microcontroller, observe button operation, and control an LED. An AT89C51 microcontroller development board with buttons and LEDs is used along with Keil μVision IDE software. Students will write code in C language to toggle the LED state each time the button is pressed. The code will be compiled to a hex file and uploaded to the microcontroller to test the button-controlled LED toggling.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Course Code and Name: Introduction to

Mechatronics Lab (ME-332L) Date:

Lab No: 05 Course Instructor: Engr. Zia Ur Rahman

Name of Student: Semester: 6th

Registration No: Department: Mechanical Engineering

Lab Task To toggle LEDS with Button press

1. To learn how to interface Button with Microcontroller.


Objectives 2. To see how Button works
3. To learn How to control Led through Buttons

 STC AT89C51 Microcontroller


 Development Board
 Keil µ vision IDE
Hardware
 Prog-ISP
and Software  Wires
Requirements  LEDs
 Buttons
 Proteus

Theory Microcontroller:
A microcontroller is a compact integrated circuit designed to govern a specific operation in
an embedded system. A typical microcontroller includes a processor, memory and input/output
(I/O) peripherals on a single chip.

Microcontroller 8051:
8051 microcontrollers are designed by Intel in 1981. It is an 8-bit microcontroller. It is built with
40 pins DIP (dual inline package), 4kb of ROM storage and 128 bytes of RAM storage, 2 16-bit
timers. It consists of are four parallel 8-bit ports, which are programmable as well as addressable
as per the requirement. An on-chip crystal oscillator is integrated in the microcontroller having
crystal frequency of 12 MHz.

Toggling:
Toggle refers to the act of switching from one view, setting, or function to another. It implies
that there are only two possible options and that a user is switching between them, and usually
these options are on or off for a specific preference.

Prepared by Tanveer Uz Zaman


Diagram:

Fig. Development Board with AT89C51 Microcontroller

Procedure  First we have to write a code in C language in keil Software.


 That code will work such a way that when button is press all the GPIO pins of port
2 toggle if it is ON so after button pressed all the LEDs should turn OFF and vice
versa.
 After that we have to create a hex file of that code. Method for creating hex file is
already discussed.
 On the basis of that code we have to make a connection of STC AT89C51
Microcontroller with LED and button.
 The hex file will be uploaded to STC AT89C51 Microcontroller through Prog-ISP.
 During uploading the power of the board should be turn ON.

Prepared by Tanveer Uz Zaman


Connection Diagram:

Fig. Connection Diagram of LEDs with Button in Proteus

Prepared by Tanveer Uz Zaman


Programming Write a code in 8051 C language to toggle LED on a button press.
Code

Results and
Conclusions

Prepared by Tanveer Uz Zaman

You might also like