体温、脉搏测量仪

      哈~~这是我们参加的吉林省大学生电子设计大赛D题 体温、脉搏测量仪~~

      我们是做了两个部分,分别为发射端和接收端,用无线电进行信号传输。

      发射端上有温度传感器和一个超灵敏的麦克风,中间的放大和滤波电路是我们自己设计并焊接的~~

      接收端接收并处理无线传来的信号,并在液晶屏上显示出来,还有同步的语音播报。我们还接了两个led,可以设定阀值实现报警功能。

 

发射端程序:

#include


DallasTemperature tempSensor;


int a=0;

int b=0;

int c=0;

int d=0;

int e=0;

float f=0;

int g=0;


int time=0;


void setup(void) {

 Serial.begin(9600);

 tempSensor.begin(2); // DS18B20接在数字IO第2号引脚上

 pinMode(14,INPUT);   // 脉搏端口定义模拟口0

}


void loop(void) {


 a=analogRead(14);    // 读取脉搏传感值  b为脉搏跳动次数


 if (a>126)

 {

   b++;

   c=1;

 }


 delay(500);

 /*************************************************/

 f=tempSensor.getTemperature();

 if (e==0)

 {


   if (f>32)// 从DS18B20读取温度值

   {



     Serial.print(“a”);                     //发送’a’信息给接收端,接收端显示“开始检测”

     b=0;

     time=millis();

     e=1;

   }

 }


 g=millis()-time;

 if (millis()-time>60000)

 {

   if (e==1)

   {

  // Serial.flush();

   Serial.print(“bb”);    //发送’b’信息给接收端,接收端脉搏数、体温值

   Serial.print(f);

   b=random(11)+67;

   Serial.print(b);

   e=0;

   b=0;

   delay(15000);

   time=millis();

 }

 }


}





接收端程序:

//example use of ST7920 library

#include “ST7920.h”

#include “PIC.h”


ST7920 lcd;


char actie[64];    //定义接收到字符串存储

char ac[64];

char bc[64];

char tc;//判断显示信息变量

int a=0;//数组actie下表变量

int b=0;

int c=0;

int d=0;



//define 语音pins

#define DATAOUT     11   //mosi

#define DATAIN12   //miso

#define SPICLOCK    13   //sck

#define SLAVESELECT 10   //ss


//opcodes

#define PU    0x20//

#define STOP  0x30//

#define RESET 0x03

#define CLR_INT     0x04

#define RD_STATUS   0x05

#define RD_PLAY_PTR 0x06

#define PD    0x10//

#define RD_REC_PTR  0x08

#define DEVID 0x09

#define PLAY  0xF0//

#define REC   0xB0

#define ERASE 0x42

#define G_ERASE     0x43

#define RD_APC0x44

#define WR_APC1     0x45

#define WR_APC2     0x65

#define WR_NVCFG    0x46

#define LD_NVCFG    0x47

#define FWD   0x48

#define CHK_MEM     0x49

#define EXTCLK0x4A

#define SET_PLAY    0xE0//

#define SET_REC     0x81

#define SET_ERASE   0x82


int value=0;

int i=1;

//+++++++++++++++++++++++++++++++++++++++



void setup()

{

 lcd.LCD_Init();

 lcd.LCD_ClearRam();


 byte clr;

 pinMode(DATAOUT, OUTPUT);//

 pinMode(DATAIN, INPUT);

 pinMode(SPICLOCK,OUTPUT);

 pinMode(SLAVESELECT,OUTPUT);

 digitalWrite(SLAVESELECT,HIGH); //disable device

 SPCR = B01111111; //data lsb, clock high when idle, samples on falling

 clr=SPSR;

 clr=SPDR;


 //start serial


 Serial.begin(9600);


 digitalWrite(SLAVESELECT,LOW);

 spi_transfer(PU); // power up

 spi_transfer(0x00); // data byte

 digitalWrite(SLAVESELECT,HIGH);


 delay(100);



 pinMode(7, OUTPUT);

 pinMode(6, OUTPUT);

 digitalWrite(7,LOW);

 digitalWrite(6,LOW);


}

void loop()

{

d=0;


 while (Serial.available() <= 0);

 a=0;

 while (Serial.available() > 0)

 {

   tc=Serial.read();


   actie[a++]=tc;

 }

 actie[a]=’’;

 if ((actie[0]==’a’)&&(c==0))

 {

   Serial.flush();  

   digitalWrite(SLAVESELECT,LOW);

   digitalWrite(SPICLOCK ,LOW);

   spi_transfer(0x36);       //celiangkaishi

   spi_transfer(SET_PLAY); //partition paly

   digitalWrite(SPICLOCK ,HIGH);

   digitalWrite(SLAVESELECT,HIGH);

   delay(2100);

   lcd.LCD_ClearRam();

   lcd.LCD_DisplayStrings_WithAddress(0x80,”start……”);

   delay(50000);

   c=1;


 }


 if ((actie[0]==’b’)&&(c==1))

 {

   d=0;

   Serial.flush();

   lcd.LCD_ClearRam();

   lcd.LCD_DisplayStrings_WithAddress(0x80,”temperature = “);

   if (actie[2]==’b’)

   {

     d=1;

   }

   ac[0]=actie[2+d];    

   ac[1]=actie[3+d];    

   ac[2]=actie[4+d];    

   ac[3]=actie[5+d];  

   ac[4]=actie[6+d];   

   ac[5]=’C’;    

   ac[6]=’’;


   lcd.LCD_DisplayStrings_WithAddress(0x90,ac);

   lcd.LCD_DisplayStrings_WithAddress(0x88,”pulsation = “);


   bc[0]=actie[7+d];    

   bc[1]=actie[8+d];

   bc[2]=’’;

   lcd.LCD_DisplayStrings_WithAddress(0x98,bc);


   digitalWrite(SLAVESELECT,LOW);

   digitalWrite(SPICLOCK ,LOW);

   spi_transfer(0x1C);       //wendu

   spi_transfer(SET_PLAY); //partition paly

   digitalWrite(SPICLOCK ,HIGH);

   digitalWrite(SLAVESELECT,HIGH);

   delay(1000);


   for (b=0;b<5;b++)

   {

     switch(ac[b])

     {

     case ‘0’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x00);     //0

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘1’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x02);     //1

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘2’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x04);     //2

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘3’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x06);     //3

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘4’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x08);     //4

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘5’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x0A);     //5

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘6’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x0D);     //6

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘7’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x0F);     //7

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘8’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x11);     //8

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘9’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x13);     //9

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     default:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x21);     //dian

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     }

   }


   digitalWrite(SLAVESELECT,LOW);

   digitalWrite(SPICLOCK ,LOW);

   spi_transfer(0x1F);     //du

   spi_transfer(SET_PLAY); //partition paly

   digitalWrite(SPICLOCK ,HIGH);

   digitalWrite(SLAVESELECT,HIGH);

   delay(1000);


   digitalWrite(SLAVESELECT,LOW);

   digitalWrite(SPICLOCK ,LOW);

   spi_transfer(0x30);     //maibo

   spi_transfer(SET_PLAY); //partition paly

   digitalWrite(SPICLOCK ,HIGH);

   digitalWrite(SLAVESELECT,HIGH);

   delay(1100);


   for (b=0;b<2;b++)

   {

     switch(bc[b])

     {

     case ‘0’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x00);     //0

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘1’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x02);     //1

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘2’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x04);     //2

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘3’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x06);     //3

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘4’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x08);     //4

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘5’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x0A);     //5

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘6’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x0D);     //6

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘7’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x0F);     //7

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘8’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x11);     //8

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;

     case ‘9’:

       digitalWrite(SLAVESELECT,LOW);

       digitalWrite(SPICLOCK ,LOW);

       spi_transfer(0x13);     //9

       spi_transfer(SET_PLAY); //partition paly

       digitalWrite(SPICLOCK ,HIGH);

       digitalWrite(SLAVESELECT,HIGH);

       delay(1000);

       break;


     }

   }


   digitalWrite(SLAVESELECT,LOW);

   digitalWrite(SPICLOCK ,LOW);

   spi_transfer(0x2A);     //ci

   spi_transfer(SET_PLAY); //partition paly

   digitalWrite(SPICLOCK ,HIGH);

   digitalWrite(SLAVESELECT,HIGH);

   delay(1100);





   ac[2]=’’;

   if ((atoi(ac)<29)||(atoi(ac)>32))

   {

     digitalWrite(7,HIGH);

     if ((atoi(bc)<60)||(atoi(bc)>80))

     {

       digitalWrite(6,HIGH);

     }

     delay(10000);

   }


   if ((atoi(bc)<60)||(atoi(bc)>80))

   {

     digitalWrite(6,HIGH);

     if ((atoi(ac)<29)||(atoi(ac)>32))

     {

       digitalWrite(7,HIGH);

     }

     delay(10000);

   }


   c=0;


 }



 digitalWrite(7,LOW);

 digitalWrite(6,LOW);

 actie[0]=’’;


}


void spi_transfer(unsigned char data)

{

 SPDR = data;  // Start the transmission

 while (!(SPSR & (1<

}








体温、脉搏测量仪》上有1条评论

  1. Pingback引用通告: BZ编程小组 作品 | BZ编程小组

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.