BASIC4MCU | 질문게시판 | 답변 : 아두이노 print write 차이점
페이지 정보
작성자 master 작성일2018-06-17 03:35 조회12,054회 댓글2건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=5537
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-06-17 오전 3:38:21// by Ok-Hyun Park//-------------------------아두이노1//int pin=4;unsigned long duration;unsigned long starttime;unsigned long sampletime_ms=30000; //sampe 30s;unsigned long lowpulseoccupancy=0;float ratio=0;//void setup(){Serial.begin(9600);pinMode(4,INPUT);starttime=millis(); //get the current time;}//void loop(){duration=pulseIn(pin,LOW);lowpulseoccupancy=lowpulseoccupancy+duration;if((millis()-starttime)>sampletime_ms){ //if the sampel time==30sratio=lowpulseoccupancy/(sampletime_ms*10.0); // Integer percentage 0=>100//Serial.println(ratio);Serial.write((int)ratio);lowpulseoccupancy=0;starttime=millis();}}//---------------------------------아두이노2//char inside;//void setup(){Serial.begin(9600);}//void loop(){if(Serial.available()>0){inside=Serial.read();Serial.println(inside);}}
댓글 2
조회수 12,054두다디다님의 댓글
두다디다 작성일아두이노 1에서 Serial.write 로 컴파일시 call of overloaded 'write(float&)' is ambiguous 라는 에러문구가 나와요..
master님의 댓글
master 작성일수정했으니 다시 돌려보세요