#include <regx51.h> // standard 8051 defines // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Include files -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= #include <lcd.h> #include <utils.h>
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Hardware Defines -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= sfr DATA = P0; sbit OUT1 = P3^4; sbit OUT2 = P3^5; sbit OUT3 = P3^6; sbit OUT4 = P3^7;
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Variables -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= char buf[20]; char code M1[] ="SPEECH: ONE"; char code M2[] ="SPEECH: TWO"; char code M3[] ="SPEECH: THREE"; char code M4[] ="SPEECH: FOUR"; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= // -=-=-=-=- Main Program -=-=-=-=-=-=-= // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= void main() { unsigned char lastdata, datanow; // -=-=- Intialize variables -=-=-= OUT1 = 0; OUT2 = 0; OUT3 = 0; OUT4 = 0; // -=-=- Intialise -=-=-= lcdInit(); // -=-=- Welcome LCD Message -=-=-= lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Speech Test"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("System"); delayms(5000); // 5 sec lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Train: 1-4 key >"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Train>Speak Now"); // -=-=- Program Loop -=-=-= lastdata=0xff; while(1) { datanow=DATA; // read data from speech board
if(lastdata!=datanow) // if there is new data then, { lastdata=datanow; switch(lastdata) { case 0x55: lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Speech too Long"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Try Again!"); break; case 0x66: lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("Speech too Short"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Try Again!"); break; case 0x77: lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint("No Match"); lcdGotoXY(0,1); // 2nd Line of LCD lcdPrint("Try Again!"); break; case 0x01: if(OUT1==1) OUT1 = 0; else OUT1 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M1); break; case 0x02: if(OUT2==1) OUT2 = 0; else OUT2 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M2); break; case 0x03: if(OUT3==1) OUT3 = 0; else OUT3 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M3); break; case 0x04: if(OUT4==1) OUT4 = 0; else OUT4 = 1; lcdClear(); lcdGotoXY(0,0); // 1st Line of LCD lcdPrint(M4); break; } } } }
is it a correct program? and what is utils.h?
The prototype (in the style defined by the ANSI standard) is not optional - it is required