BASIC4MCU | 질문게시판 | 답변 : 온도센서로 스위치 역할을 코딩부탁드립니다 ㅠㅠ
페이지 정보
작성자 master 작성일2018-12-16 08:27 조회3,412회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=6937
본문
하고자 하는 방향은 이렇습니다.아두이노 쉴드에 블루투스+온도+심박센서 를 연동하는것인데요블투+심박코드와 온도아두이노 코드를 합치고 싶습니다근데 여기서 관건은 온도가 20 도 이하일경우인데요1.심박이 무조건 100으로 출력되기2.블루투스모듈이 꺼지기둘중 하나만 충족이 되면 됩니다.만약 온도가 20도 이상이라면 블루투스를통해 측정된 심박만 전송이되는거고요...다소 까다롭지만...부탁드립니다 ㅠㅠㅠ
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-12-16 오전 8:36:19// by Ok-Hyun Park//#include <math.h>//#include <Wire.h>//#include <SoftwareSerial.h>SoftwareSerial mySerial(2,3); //블루투스의 Tx,Rx핀을 2번 3번핀으로 설정//int B=3975; //B value of the thermistorint a;long t=0;float temperature;float resistance;//void setup(){Wire.begin();Serial.begin(9600);mySerial.begin(9600);}//void loop(){if(millis()-t>500){ t=millis(); // 500ms 마다 처리a=analogRead(A0);resistance=(float)(1023-a)*10000/a; //get the resistance of the sensor;temperature=1/(log(resistance/10000)/B+1/298.15)-273.15; //convert to temperature via datasheet;Serial.print("Current temperature is "); Serial.println(temperature);//Wire.requestFrom(0xA0>>1,1);while(Wire.available()){unsigned char c=Wire.read();if(temperature>20){ Serial.println(c,DEC); mySerial.println(c,DEC); }else { Serial.println(100); }}}//if(mySerial.available()){Serial.write(mySerial.read());}if(Serial.available()){mySerial.write(Serial.read());}}
댓글 0
조회수 3,412등록된 댓글이 없습니다.