In this tutorial, we illustrate how to write C program that turns on and off a LED connected to the port of a Intel 80C51 microcontroller chip. Such simple project forms the basis of embedded software development with C.
Intel 80C51 is an 8 bit microcontroller used in many areas of embedded systems design. For our purpose here it should be noted that the 80C51 has 4 ports called Port0, Port1, Port2 and Port3. All of these are bidirectional port. Each of the port has 8 pins and each of them can be written to and read from. So there are 4x8=32 I/O ports.
Port 1 is different from others in that it is designed as an I/O port. Other ports additional to input/output function also provides other special functions which will not be discussed here.
Here we will look at how the individual pins of the Port 1 can be controlled. That is how to send a bit, read a bit and how to send a byte and read a byte. This is how you usually begin learning a microcontroller and C programming as well.
We will start by writing 1 bit to the port 1 pins.
Consider the following schematic:

In the above figure, a LED is connected to the Port 1, pin 0. So to turn on the LED we must have logic high at the port pin 0. The C program for doing this is as follows,
#include <reg51.h>
sbit mybit = P1^0;
void main(void)
{
mybit = 0;
}
In the above code, the Port 1 bit 0 is assigned a variable called mybit is declared using the sbit data type. In the main function this variable is set to 0 meaning that port 1 bit 0 is set to logic 0 and therefore doing this will not turn on the LED.
But if we change the above code so that mybit = 1; then now the Port 1 bit 0 has logic 1 high and therefore due to the potential difference created between that pin and the ground current flows into the LED and the LED turns on.
So to turn on the LED we would write the C program as follows:
#include <reg51.h>
sbit mybit = P1^0;
void main(void)
{
mybit = 1;
}
The result is shown,

Notice that the LED is turned into blue.
In the above schematics we did not limit the current through the LED. One should add a resistor to limit the current flowing into the LED so that it does not get excessive current otherwise it will burn and get damaged.
So lets add a resistor before we move on. The LED has 2.2V forward voltage and current limit of 10mA. If the Pin voltage is at 5V then we can calculate the resistor value to limit the current into the resistor to 10mA.
R = (5V-2.2V)/10mA = 380 ohm ~370ohm.
OK, see the diagram below

Above we showed you how to turn off and on a LED at the port 1 pin 0 of the microcontroller.
In next tutorial post we illustrate how to write program with delays to turn on and off the LED.
For learning what is Proteus and how it is useful for embedded system development see the blog post- Embedded Systems Programming with Proteus Software.
Intel 80C51 is an 8 bit microcontroller used in many areas of embedded systems design. For our purpose here it should be noted that the 80C51 has 4 ports called Port0, Port1, Port2 and Port3. All of these are bidirectional port. Each of the port has 8 pins and each of them can be written to and read from. So there are 4x8=32 I/O ports.
Port 1 is different from others in that it is designed as an I/O port. Other ports additional to input/output function also provides other special functions which will not be discussed here.
Here we will look at how the individual pins of the Port 1 can be controlled. That is how to send a bit, read a bit and how to send a byte and read a byte. This is how you usually begin learning a microcontroller and C programming as well.
We will start by writing 1 bit to the port 1 pins.
Consider the following schematic:

In the above figure, a LED is connected to the Port 1, pin 0. So to turn on the LED we must have logic high at the port pin 0. The C program for doing this is as follows,
#include <reg51.h>
sbit mybit = P1^0;
void main(void)
{
mybit = 0;
}
In the above code, the Port 1 bit 0 is assigned a variable called mybit is declared using the sbit data type. In the main function this variable is set to 0 meaning that port 1 bit 0 is set to logic 0 and therefore doing this will not turn on the LED.
But if we change the above code so that mybit = 1; then now the Port 1 bit 0 has logic 1 high and therefore due to the potential difference created between that pin and the ground current flows into the LED and the LED turns on.
So to turn on the LED we would write the C program as follows:
#include <reg51.h>
sbit mybit = P1^0;
void main(void)
{
mybit = 1;
}
The result is shown,

Notice that the LED is turned into blue.
In the above schematics we did not limit the current through the LED. One should add a resistor to limit the current flowing into the LED so that it does not get excessive current otherwise it will burn and get damaged.
So lets add a resistor before we move on. The LED has 2.2V forward voltage and current limit of 10mA. If the Pin voltage is at 5V then we can calculate the resistor value to limit the current into the resistor to 10mA.
R = (5V-2.2V)/10mA = 380 ohm ~370ohm.
OK, see the diagram below

Above we showed you how to turn off and on a LED at the port 1 pin 0 of the microcontroller.
In next tutorial post we illustrate how to write program with delays to turn on and off the LED.
For learning what is Proteus and how it is useful for embedded system development see the blog post- Embedded Systems Programming with Proteus Software.




Who doesnt know about Tom and Jerry! They are definitely the best known cat and mouse in the whole world. Brought to us by William Hanna and Joseph Barbera in 1940, they continue to participate in lives of today’s generation of kids. The plots of each cartoon usually center on Toms numerous attempts to capture Jerry and the mayhem and destruction that ensues. Tom rarely succeeds in catching Jerry, mainly because of Jerrys cleverness, cunning abilities, and luck. Interestingly enough, many of the title cards show Tom and Jerry smiling at each other which seems to depict a love-hate relationship rather than the extreme annoyance each displays towards the other. Anyway, those exact cat and mouse are the reason for our site to exist. We enjoyed watching their cartoons and also playing Tom and Jerry Games. We found the best games there are to find and brought them to you rig
This is the best place on the web for you to play tom and Jerry online games! You can choose from playing games, maybe coloring some very interesting Tom and Jerry pictures or solving puzzles of these great cartoons. If you still need some historical details about these two great cartoon characters, you may find some on Wikipedia. We also provide all kinds of cartoon games and more.
Hello and welcome to the magnificent world of Tom and Jerry! From small kids to grandparents, we all love Tom and Jerry. This site exists with the purpose of entertaining you with the best Tom and Jerry Games that can be played online. We have more than 20 games for you to enjoy and we are working on adding more games for you to play so have fun with Tom and Jerry!






