here are the driver files
File1: Irdirection.h
/*
robox irdirection
auther:haishen
date:2012.6.21
test in atmega1280
from:arduino.cn
*/
#ifndef IRDIRECTION_H_
#define IRDIRECTION_H_
class irdirection
{
public:
irdirection();
int fire(char temp);
private:
int sj;
};
#endif
File2 : Irdirection.cpp
/*
robox irdirection
auther:haishen
test in atmega1280
date:2012.6.21
from:arduino.cn
*/
#include <arduino.h>
#include "irdirection.h"
irdirection::irdirection()
{
Serial1.begin(4800); //³õʼ»¯Ó²¼þ´®¿Ú1£¬Îª±£Ö¤Í¨ÐÅÎȶ¨£¬arduinoÓëÄ£¿éÖ®¼äµÄͨÐÅÉèÖÃΪ²¨ÌØÂÊ4800
}
int irdirection::fire(char temp)
{
//unsigned int sj;
unsigned char i;
unsigned char hc[5];
Serial1.print(temp);
while(1)
{
if(Serial1.read() == 0X0A)//¼ì²â½øÈë
break;
}
for(i = 0; i < 5; i++)
{
while(1)
{
if(Serial1.available())//½ÓÊÕ×Ö·û
break;
}
hc = Serial1.read();
- }*
- sj = 0;*
- for(i = 0; i < 5; i++)*
- {*
if((hc >= 48) && (hc < 58)) //ÅжÏÊÇ·ñ½áÊø
* {*
_ sj = sj * 10 + hc - 48;
* }
else*
* return(sj);
}
// return(0xffff);
}
Irdirection.cpp (915 Bytes)
Irdirection.h (333 Bytes)*_