/*Stepper motor Control*/
#include<stdio.h>
#include<dos.h>
#include<conio.h>
void main()
    {
        int ctr, pb;
        clrscr();

        do {
            pb= inportb(0x379);
            pb= pb & 0x70;
            if (pb==0x60) /*Pb1 is pressed*/
                {
                    clrscr();
                    textcolor(BLINK+WHITE); cprintf("Forward rotation");
                    ctr=0;
                    while(ctr<6)
                        {                            
                            outportb(0x378,0x06);
                            delay(10);
                            outportb(0x378,0x05);
                            delay(10);
                            outportb(0x378,0x09);
                            delay(10);
                            outportb(0x378,0x0a);
                            delay(10);
                            ctr++;
                        }
                }/*if pb1*/
            else if (pb==0x50) /*Pb2 is pressed*/
                {
                    clrscr();
                    textcolor(BLINK+WHITE); cprintf("Forward rotation");
                    ctr=5;
                    while(ctr>=0)
                        {
                            outportb(0x378,0x0a);
                            delay(10);
                            outportb(0x378,0x09);
                            delay(10);
                            outportb(0x378,0x05);
                            delay(10);
                            outportb(0x378,0x06);
                            delay(10);
                            ctr--;
                        }
                }/*else if pb2*/
            }while(pb!=0x30);
    }/*main*/

/* Note: Use the BACK button of your browser to return to the previous page  */

Hosted by www.Geocities.ws

1