How to program for 8051 microcontroller

August 31, 2011 — 95 Comments

Tools you need for writing 8051 micro controller:

Here are the some of tools used for 8051 microcontroller programming and simulation

  • A51-Assembler
  • Code editor -Syntax highlighting Notepad.
  • Simulator-windows based Smart n Small Simulator.
  • Baud -Timer value calculators for various baud rates.
  • C compiler for 8051.
  • RIDE software – simulation Click here
  • Keil uVision – 8051/ARM simulation Click here (most preferred)
  • Proteus – Fully embedded simulation software  Click here

Here we will work on Keil Uvison4 simulation software to make our simulation before burning program into 8051 chip.

  • Install sofware on your system
  • Click Project -> New Uvision Project
  • Save your project
  • Select Target Device (8051 – AT89s51)
  • File -> New

New text-editior will be opened. Here you need to write your code:

In this tutorial we will see blink LED program as beginners

sbit en=P0^0;
void delay();
void delay()
    int i,j;

        en = 0;
        en = 1;

LED will get ON/OFF depending on delay function as specified in the about program

After typing this program save this file (with file extension *.c).
Right click source Group add files to source group. Choose your saved file wit extension “.c”.
After adding your code file to source group.
Go to “project” menu click “Build Target”
You should get zero errors after compile it.
Once you done with your compilation click “Debug” Menu click “Run”

Now your simulation will run where you can see the port0 which will be blinked depending on delay specified in your code.

Thats it!! You’re done with your simulation. In next article article will teach you how to burn code into the 8051 microcontroller chip. Please make your doubts in the comments section.



95 responses to How to program for 8051 microcontroller

  1. Dear sir,
    we are pursuing our project. we want to load program in intel p8051ah microcontroller. we found many ways to program in controller but we cant find the way. its helpful to send the programmer circuit & programming software for our required controller. kindly send to my mail id. thank you

  2. i want to know that if i want to get any output from a particular port of microcontroller then should i send 0 or 1 to that port’s pin. i am using AT89S52.
    please help me.
    thank you.

  3. Dear Sir,
    With due respect I would like to express that we are pursuing our project on electronics
    as a final year B.Tech student of Electrical & Electronics Engineering. The main aim of of the
    project is to make a circuit of streetlight that glows on detecting the vehicle movement.
    The components that we are using are:
    • ATmega8 microcontroller
    • DS1307 IC
    • PIR sensor
    • LDR
    • LCD
    • LED array
    The questions that I want to ask are these:
    1.Can we use the AVR board that contains the AT mega8 microcontroller and a bread board separately for adding some of other components to that AVR board?
    2.How can we fuse our program in the AVR board containing the ATmega8 controller?
    3.Can you send a sample copy of the program that we will be using to implement the circuit?
    Waiting for your early response .

    from Subhrajit Dey

  4. I want to know one thing sir. Is AT89Sxx programmer is feasible for
    AT89Cxx? Or source code of AT89Sxx & AT89Cxx will
    be same for any project.
    Bcoz I m doing Automatic railway gate controller project.

  5. sir i need to improve my both electronics hardware and software. can u suggeat any idea to improve my knowledge on both harware and software in electronics please help me .. i neeed a good guide

  6. hi,
    I am work with atmel at89c51rc2 controller but here i try to dump the programming through ISP by software of FLIP it shows an time out error i Don’t kw what to do, so please can you suggest me any solution for that..

    • Hi, First can you check whether board/chip detected on your system on parallel port?

      Alternative way is to have 89C51 programmer board to dump your hex code on chip.

  7. i want the coding and simulation for pick and place robotic arm controlled by android smart phone using blue control app

  8. i want the coding and proteus simulation of pick and place robotic arm controlled by android smart phone using blue control app.

  9. hi……… sir m a student n working on a project on auto intensity street light control ,using atmega 8 i bought a nano built in kit for atmega8 and i need to do programming regarding street light control sir can you help me in writing a program…….!!!!!!!!!!!!!!!!!!!!! i have no idea on what codeing i need to be doing

    • Hozefa kanchwala November 11, 2014 at 3:10 pm

      Go for AVR Studio. Simulate your program in avr studio 5.2 or 6.
      Before Simulating Design a Schematic Capture of your Project on Proteus 8.2 and run your program in Schematic.

  10. i hav subjct on microcontroller but i dont understand anything not even basic so i wanna learn n know about it…plz help me..

  11. sir…i hav a kit 8051 with RS232..keil software…suggest me projects with it

  12. i just start now learning embedded c,please give a reference books for learn embedded c.please reply me as soon as possible.

    • I too new for Embedded C. so if u get any materials send to my mail id it will be useful for me, because nw i am working in embedded based company

  13. sir i have max 232 ic base programer , DB9 connector and usb to serial cable db9 sir my programer is not connet with pc i intall cable driver but programer is not connected and i use flash magic and sir which software use for at89s52
    thank you

    • Actually flash magic is philips product, so only those controller made by Philips can be program through it.
      89s52 is Atmel product so check Atmel official web site and download microcontoller ISP software. .

  14. please tell me how to burn code into the 8051 microcontroller chip.

  15. Hi Jagan
    I am enthusiastic to learn about embedded systems.Can you help me in learning.?
    I want to start form basics,so would you like to guide me?

  16. AT 89C51 how to program,i want control of 24vDC 8 value controlling

  17. I need the program of RFID Based Security System Project .Can you please tell me the link where i get the program.

  18. sir can u tell me that is c and c++ is sufficient for microcontrollar coding or i need to learn assembly language for that specially………..

  19. hello sir my name is chandru plz send 8051 microcontroler program for wirless led display using gsm modem

  20. hello jagan iwant the program of embedded c or assembly language for speed checker to detect rash driving on highways using microcontroller at89s52 plz

  21. sir,i am doing project on embedded systems and i did not know how to write program for” speed checker to detect rash driving on highways using microcontroller AT89S52″.
    plz help me ….

    • Install two ir sensor a part frome some distance.
      and use first sensor to trigger the timer of microcontroller and
      use second sensor to stop the timer of micro controller.
      now you can easily calculate speed by = distance between two sensor / timer value

  22. hi this is vinay, im working on a project of security system using at89c51 i want to use a simple camera, which should start recording on opening a door or when a security is breached,please suggest me which cam and microcontroller, should i use and how to process and store the video in memory i dont know any thing about camera,microcontroller interfacing,and storing… i need to show a demo storing of even 5mb video of any resolution is acceptable……….

  23. how can i learn to write a program code own for micro controller

  24. I want to learn programming micro-controller 8051. I am a hobbysist .
    I like to make electronics projects….

    please tell me how I can learn this. I am a graduate ….and I know the programming of microprocessor 8052.. by kit….

    so please tell me the steps that how can I learn programming uc8051….

  25. Hey, the only thing happens is that stays on the whole time, but it doesn’t blink.

  26. my project is bluetooth controlled home automation by using android application….so help in coding my microcontroller…….i am thnkful to u

  27. PLZ, HELP mr.Jagan i download a software of keil c51 and i install it but it was a evaluation version i want to get license number i did not have PSN number of keil software , anybody know please help from where i get product serial code of keil

    • Try evaluation version by providing contact information on Keil website

      • hello sir,
        i need your contact
        your mail ID and contact number will be very helpful for me
        i am a ECE student from trichy tamilnadu
        seeking for you reply soon thanks in advance

      • I am just a beginner . I dnt know how to program a micro controller. Can you suggest me a website/book through which i can study how to use a microcontroller?

      • please help me mr.jagan i am doing project on auto intensity street light controller but i have some problem with to write a programm can u help me…

  28. how to generate hex file using Keil Uvison?

    • PLZ, HELP i download a software of keil c51 and i install it but it was a evaluation version i want to get license number i did not have PSN number of keil software , anybody know please help from where i get product serial code of keil

    • Go to “project” menu click “Build Target”
      You should get zero errors after compile it.
      Once you done with your compilation click “Debug” Menu click “Run”

      Check for Hex file

  29. Hi jagadesh! I badly need your help very fast.. I’m doing a project( Contactless digital tachometer using 8051 micro controller) on AT89S51. I just don’t know how to dump program into that microcontroller. I please request you to suggest the software as well as software dumping hardware like pocket avr programmer or usb tinyISP and also please give procedure or instructions to dump into that microcontroller. You can have a look on my project in
    . Thanking you in advance…

  30. Hello!

    I’m new with this controller. I have to complete a project at school using it. My problem is that I can only use assembly language. Can you help me out with some links? I googled but couldn’t find usefull stuff for beginners and the time is running. Many thanks and greetings from Hungary!

  31. sir i need to know how to program a tilt sensor in 8051 microcontroller…..

  32. hey Jagan,

    I want to display P C M E
    12 11 10 09
    K H E C
    05 06 07 08
    My LEd Matrix is 16*12,i am using MSP430G2231 Launchpad.
    Can you help me out.
    it has a delay of 3 hrs after three 3hrs in place of P C M E we get K H E C….
    and after 24hrs we get this thinng C M E P
    11 10 09 12
    H E C K
    06 07 08 05

    will be displaying.
    The crystal freq is 32Mhz.

  33. Palash Chakraborty September 2, 2013 at 12:50 am

    Hi Jagadesh,
    I want to burn a hex code into ATMEGA32 micro-controller. Can u please tell me what would be the best hardware to burn it. Please suggest me some name. Also please tell me how many times i can burn the hex code into the same micro-controller.

    • Just ask for ATMEGA Programmer kit in market. They will give you hardware it costs around Rs.1200 to 2000 depends on market. You can burn hex codes based on erase cycle times specified on your microcontroller datasheet. Approx 10000 times. For accurate information, please verify the datasheet. Thanks

  34. I am a third yr student of electrical engg. I don’t know anything about microcontroller, please tell me things I required to control motion of dc motor.

  35. I want tu use a microcontroller as a transmitter and a receiver…. is tis possible? Am a beginner… if possible i want tu know if there r any programs for tat? Can u pls help me wit it? its a little urgent pls

  36. hi,i would like to know how to burn program into rom of mc.

  37. sir,how to compile a program in microcontroller 8051

    • You need to compile using Uvision software. Write your program in Uvision and compile on the software which will give you HEX file as output. This HEX file will be used for burning the code into microcontroller using kit.

  38. I am just a beginner . I dnt know how to program a micro controller. Can you suggest me a website/book through which i can study how to use a microcontroller?

  39. Himanshu singh July 20, 2013 at 10:36 am

    Hi.. I wana to get perfection in coding for controller so help me out. For more now i’m working on 8051 microcontroller.
    please tell the websites which provide codes for several- led,dc motor,stepper motor etc….
    Also suggest some points how yo improve coding.

  40. Hello Sir,
    Pl. help me. I’m new to microcontrollers. & To start, U hv given the following list of things that are needed:-
    [A51-Assembler; Code editor; Simulator ; Baud ;C compiler for 8051;
    Then U give :- RIDE software; simulation ; Keil uVision – 8051/ARM simulation; Proteus – Fully embedded simulation software.]
    …Now, I understand that, I hv to download only the three software given at end of the above list, which will include all the above things like AS1, Simulator etc.,?
    But the download site has many options. It is v. confusing for a beginner, as to what to download? Can u give me a guide & steps to download these softwares? Hv U given links in ur tutorial which can show me the STEPS required to be able to download these softwares?
    Navin Datt

    • Hi Navin,

      Download C51 Version of Keil uVision – 8051/ARM simulation from the above steps. That will be useful for your coding, compilation and simulation of controller projects (To test the output of ports without hardware based on your program).


  41. everything worked but when pressed create hex file then nothing happened..
    why is this so?

  42. i am a student from sierra leone. I want to design an auto intensity street light control sytem. But from research, it it advisable to use an 8051 microcontroller with a keil compiler. But am having problem getting these items in my country. I want to order them, but honestly i having being seaching and reading a lot. I need a complete kit to do that project. From my own undastanding i no i need an AT89CXX series and a keil compiler software. But i just cant figure d hardware programmer to use inorder to programme d microcontroller. Can you please help me with all the details of what i should get to do the project. Can i also use a PIC to do it ?

  43. sir can you pls send me at89c51 programming kit circuit diagram cause i want to make it ……pls send me on my email address thank you…….. May 15, 2013 at 11:12 pm

    sir can you pls send me at89c51 programming kit circuit diagram cause i want to make it ……pls send me on my email address thank you……..

  44. hi jagan sir,
    I have hex file for AT89C2051. How can I check that my program will run on microcontroller.

  45. Hi….I m using BASCOM for programming ….how i can burn the program to the micro-controller…….

  46. Hi Jagan! Good explanation. I would like to get an idea about the coding for various projects. So, I am expecting few more this kind of posts from you.

  47. harold macaranas February 26, 2013 at 2:54 pm

    hi i have alexan 89cx051 programmer but i dont have any idea how to use it to burn an hex file into atmel 89c2051 please help me..

  48. sir, i m student & working on 8051 project. i want to known that how can i loaded microcontroller with my program. which type of hardware & software need for this

    • What your microcontroller series? Its AT89CXX or AT89SXX series? If AT89CXX series you need to buy programmer of AT89CXX series. If you want built own kit then you can go AT89SXX series controllers.

      • harold macaranas February 26, 2013 at 6:21 pm

        how can i used the alexan atmel 89cx051 programmer?can i need a software to used that prommer sir please help…..

        • Yes You need the software which is compatible for your 89cx051 programmer. Once the software you need to find your controller and select the HEX file. Once the HEX file selected click burn/write button and wait to get it completed. Then you’re done. After burning controller test it with your kit.

      • Is there need of any type of software to burn program in AT89SXX or AT89CXX. Which circuit is capable for my own kit

  49. Hi, I am a student doing a project using AT89C2051. Please tell me which programmer (software + hardware kit) is required for burning the hex files in the AT89C2051.. Please tell about AT89C2051 only..

    • Hi Shubham, Get it touch with the electronics shop where you bought the AT89C2051 microcontroller chip. They will be able to provide the hardware burning kit and software in the package.

  50. i am a student ,abhishek.i am working on project rf remote controle robote car using ic at89c2051how to burn the hex code on ic if i dont have any kit ………..what would i require to do so……i need to know is there any module using that i can burn an ic .is there if it is please tell me ……..and send me your email id so i can contact u for guidence as i am new family member of micro family

  51. I have a AT168 development board (Arduino Uno). I want to program a AT89C2051 micro-controller using that board. And burn the code using Keil into it. Is this possible?

  52. can u pls specify me a software name to dump a program in 8051.i have the kit but i dint get the cd along with it

  53. Where can i find the next article ? Please send or post a link ! i need it urgently ! Thank you !

  54. patel manoj j July 9, 2012 at 11:18 am


  55. i have an 8051 kit which comes with atmega16 , a serial rs232 port with max 232 ic and necessary connections for Vcc , gnd and oscillator . How do i burn hex code into mCU using this rs232 port , i use keil uVision4 for simulation and creating hex files . Do i need other softwares for dumping the code ?

  56. How to burn the hex file in the microcontroller. Any circuit diagram For programmer for AT89C51 microcontroller please tell me……..

    • HI Sanket, You will be having mircocontroller AT89C series burning kit for to burn the hex file to your microcontroller. You can burn using the kit.. If you need to design own means kit you should go for AT89S series microcontroller, kit can be designed in home itself using Parallel port connection.

    • Hi sanket. There is a downloader for the program. You can make it by own.

Trackbacks and Pingbacks:

  1. 8051 Microcontroller - Programming Tutorials, Simulators, Compilers and Programmers - April 5, 2013

    […] How to Program For 8051 Microcontroller – short tutorial with tools and steps to program the microcontroller in order to blink an LED. The tutorial can be useful for beginners. […]

Leave a Reply


Text formatting is available via select HTML. <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>