업무 볼타입 카운터_아두이노
개발 관련 설명
아두이노를 활용하여 제어 가능하도록 GPIO 3번을 이용하고 수신해서 장비 돌리는 샘플 예제 이다.
개발 환경 설치
아두이노 코드
int outputPin = 3; // Connect sensor to input pin 4
String inString = ""; // string to hold input
int i_delay_time=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(outputPin,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(Serial.available() > 0) { //시리얼에 값이 있으면
int inChar = Serial.read();
if (isDigit(inChar)) {
// convert the incoming byte to a char and add it to the string:
inString += (char)inChar;
}
// if you get a newline, print the string, then the string's value:
if (inChar == '\n') {
i_delay_time =inString.toInt();
// clear the string for new input:
inString = "";
// GPIO 껐다 키기
Serial.print("_____START");
digitalWrite(outputPin,HIGH);
delay(10);
digitalWrite(outputPin,LOW);
delay(i_delay_time);
digitalWrite(outputPin,HIGH);
delay(10);
digitalWrite(outputPin,LOW);
Serial.print("____FINISH");
}
}
}
댓글남기기