can anyone help me on how to make this program short? what this program does is that its Initially on : R=1x1 off to the right, L=1x1 off to the left, G= night rider one cycle, S= off. This kind of program is made to control a micro controller...i need your help as soon as possible...thanks
#include <reg420.h>
#include <stdio.h>
#include <ctype.h>
#include "serial.h"
void delay();
void delay2();
void main()
{
char o;
InitSerialHardware();
do {
o = getchar();
P1 = 0xFF;
if(isspace(o)) continue;
o = toupper(o);
if(o == 'S')
{
puts(" Stop");
P1 = 0;
}
if(o == 'L')
{
puts(" Left");
P1 = 0x01;
delay();
P1 = 0x02;
delay();
P1 = 0x04;
delay();
P1 = 0x08;
delay();
P1 = 0x10;
delay();
P1 = 0x20;
delay();
P1 = 0x40;
delay();
P1 = 0x80;
delay();
}
if(o == 'R')
{
puts(" Right");
P1 = 0x80;
delay();
P1 = 0x40;
delay();
P1 = 0x20;
delay();
P1 = 0x10;
delay();
P1 = 0x08;
delay();
P1 = 0x04;
delay();
P1 = 0x02;
delay();
P1 = 0x01;
delay();
}
if(o == 'G')
{
puts(" Go Night Rider");
P1 = 0x01;
delay2();
P1 = 0x02;
delay2();
P1 = 0x04;
delay2();
P1 = 0x08;
delay2();
P1 = 0x10;
delay2();
P1 = 0x20;
delay2();
P1 = 0x40;
delay2();
P1 = 0x80;
delay2();
P1 = 0x80;
delay2();
P1 = 0x40;
delay2();
P1 = 0x20;
delay2();
P1 = 0x10;
delay2();
P1 = 0x08;
delay2();
P1 = 0x04;
delay2();
P1 = 0x02;
delay2();
P1 = 0x01;
delay2();
} cx
else continue;
} while (1);
}
void delay()
{
int x, y;
for(x=0;x<255;x++)
{
for(y=0;y<255;y++)
{
}
}
}
void delay2()
{
int x, y;
for(x=0;x<200;x++)
{
for(y=0;y<100;y++)
{
}
}
}