Tutorial Microcontroller 8051
 
 
 
 
 
   

BACK

Software Line Follower Robots Microcontroller 8051:
Software for write to AT89C2051 is robot1.hex ,which was written by C-language ,the source code is robot1.c compiled by using MIDE-51, you can download this compiler from here.

#include 8051io.h #include 8051reg.h extern register unsigned char speedleft,speedright; register unsigned char high,low,flag,time;

main()
    {
           P1=0x40;
           P3=0xff;
           high = 80;
           low = 30;
           flag = 0;
           time = 50;
           Start();
           while(1) {
           P3|= 0x0f;
           Run();
           }
           }
Start()
           {
           char exit,key;
           exit =1;
           while(exit)
           {
           key = P1;
           if((key & 0x40)==0) exit=0;
           }
           } 
Run()
           {
           char sensors;
           sensors = (P3 &=0x0f);
 if((sensors & 0x01)==0) {
           TurnRight();
           flag = 1; }
 else if((sensors & 0x08)==0) {
           TurnLeft();
           flag = 2; }
           else if(sensors == 0x09) {
           Forward(high);
           flag = 0; }
 else if(((sensors==0x0b)||(sensors==0x0d))&&(flag==0))
           Forward(low);
}
Forward(char speed)
           {
           P1=0x64;
           speedright = speed+10;
           speedleft = speed;
           delay(time);
           }
TurnRight()
           {
           P1=0x68;
           speedright = low+5;
           speedleft = low;
           delay(time);
           }
TurnLeft()
           {
           P1=0x54;
           speedright = low+5;
           speedleft = low;
           delay(time);
           }
Reverse(char speed)
           {
           P1=0x58;
           speedright = speed;
           speedleft = speed+5;
           delay(time);
           }
Best Link

 

BACK

 

Lesson 1:
T o o l
1.1. Programmer
1.2.
Edsim 51
1.3. MIDE-51
1.4. ATMEL ISP

Lesson 2:
Input Output
2.1.LED
2.2.Swicht
2.3.7 Segmen
2.4.LCD Character
2.5.ADC
2.6.DAC
2.7.Motor Stepper
2.8.Keypad

Lesson 3:

Timer Counter

3.1.Basic
3.2.Mode 0
3.3.Mode 1
3.4.Mode 2
3.5.Mode 3

Lesson 4:

Serial Comm.

4.1.Basic
4.2.LED
4.3.Rotate LED
4.2 ADC
4.3.LCD

Lesson 5:
Interuption

5.1.Basic
5.2.Timer
5.2.External