개요 (Outline)
<2019 서울과학고 아두이노 프로젝트>
학생들이 화학 시약 정리를 잘 하지 않는다는 문제점을 해결하기 위해, 위와 같은 기계를 만들었다. 이 기계는 간단한 모형으로, 실제 시약이 아니라 작은 플라스틱 병과 캔을 이용했고, 공간도 2개로만 나눠져 있다. 하지만 이를 응용한다면 효율적이고 편한 정리 기계를 만들 수 있을 것이다.
<2019 Seoul Science High School Aduino Project>To solve the problem that many students doesn't place back chemical reagents at the right position, we created this machine. This is a simple model, so we used small plastic bottles or cans, not real reagents, and the space is divided into only by two. But if we applicate this model, we could make efficient and convenient lab cleaning machine.
작동 개요 (How it works?)
바코드 인식 -> 설정해놓은 위치로 이동 -> 병 밀기 -> 원위치로
Barcode Recognition -> Setting Proper Position -> Pushing the Bottle -> Setting Original Position
동영상 (Video)
설명 (Explanation)
1. 바코드 인식 (Barcode Recognition)
병을 엘리베이터에 올려 놓으면, 바코드 스캐너가 병에 부착된 바코드를 인식한다.
Put the bottle in the elevator. Then, the barcode scanner recognizes the barcode attached to the bottle.
CODE Explanation_
바코드 스캔은 바코드 스캐너 오픈 소스 코드를 이용했다.
Used Barcode Scanner open source code for scanning barcode.
+) 바코드를 인식하기 전('action==0'), LED는 초록색이다.
+) Before barcode is recognized ('action==0'), the LED is green.
if (action == 0) {
digitalWrite(RED_LED_PIN, HIGH);
digitalWrite(GREEN_LED_PIN, LOW);
digitalWrite(BLUE_LED_PIN, HIGH);
}
2. 설정해놓은 위치로 이동 (Setting Proper Position)
인식한 바코드 정보에 따라 엘리베이터가 알맞은 위치로 움직인다. (바코드의 맨 앞자리 수 7->1층, 8->2층) 엘리베이터는 도르래를 통해 올라가다가, 포토 인터럽터가 엘리베이터가 2층에 도착했음을 인식하면 멈춘다.
Elevator moves to the proper position according to the barcode information recognized. (Barcode's 1st digit 7->1F, 8->2F) The elevator goes up by the pulley, and when the elevator reach 2nd floor, photo interrupter recognizes the elevator, then elevator stops.
엘리베이터의 뒷부분에 부착된 부분이, 원하는 위치에 도착하면 photo interrupter의 사이에 있도록 한다.
When the elevator arrives at the proper position, the part attached to the back of the elevator is placed between the photo interrupter.
CODE Explanation_
if (barcode_input[0] == '8') {
if (action == 0) {
action = 1;
digitalWrite(RED_LED_PIN, LOW);
} else {
Serial.println("under processing - ");
Serial.println(action);
}
} else if (barcode_input[0] == '7') {
if (action == 0) {
action = 2;
digitalWrite(BLUE_LED_PIN, LOW);
} else {
Serial.println("under processing - ");
Serial.println(action);
}
}
barcode_input[0]에 저장된 바코드의 맨 앞 자리 수에 따라 action에 다른 값을 저장한다. LED의 색도 바뀐다. (8인식 -> 빨강, 7인식->파랑)
Store different values in 'action' depending on the first digit number of the barcode, which is stored in 'barcode_input[0]'. Color of LED changes too. (8->red, 7->blue)
if (action == 1) {
Serial.println("Motor up start");
StartMotorB(FORWARD);
action = 11;
} else if (action == 11) {
if (digitalRead(PhotoInterrupter1_pin) == HIGH) {
Serial.println("Motor up end");
StopMotorB();
delay(500);
action = 12;
}
action==1 (바코드의 맨 앞 자리 수 8)이면, 도르래에 연결된 MotorB를 작동시킨다. 그리고 PhotoInterrupter가 엘리베이터를 인식하면 MotorB의 작동을 멈춘다. ('action'의 값을 계속 검사하고 있는 loop문 안의 코드 중 일부이다.)
If 'action==1' (Barcode's 1st digit 8), activate the motorB, which is connected to the pulley. And when PhotoInterrupter recognizes the elevator, the motorB stops working. (This is a part of the code in the loop statement, which continues to examine the value of 'action')
3. 병 밀기 (Pushing the Bottle)
모터에 의해 톱니가 돌아가면, 래크 기어가 이에 맞물려, 병을 미는 방향으로 움직인다. 병을 민 후, 래크 기어는 다시 원위치로 돌아온다.
When the cogwheel is turned by the motor, rack gear engages and move in direction of pushing the bottle.
CODE Explanation_
else if (action == 12) {
//Motor slide
Serial.println("Motor slide start");
digitalWrite(RED_LED_PIN, HIGH);
digitalWrite(GREEN_LED_PIN, HIGH);
digitalWrite(BLUE_LED_PIN, LOW);
StartMotorA(FORWARD);
delay(1500);
action = 13;
} else if (action == 13) {
StopMotorA();
delay(500);
action = 14;
} else if (action == 14) {
StartMotorA(BACKWARD);
delay(1500);
action = 15;
} else if (action == 15) {
StopMotorA();
Serial.println("Motor slide end");
delay(500);
action = 16;
}
톱니를 돌리는 MotorA의 움직임을 시간으로 조정한다. 이에 따라 래크 기어는 앞으로 가다가, 멈추고, 뒤로 돌아가다가, 멈춘다. 이때 LED의 색은 파랑색이다.
Motion of the motorA that turns the cogwheel is adjusted by time. Accordingly, the rack gear then moves forward, stops, turns backward, and stops. At this time, the LED is blue.
4. 원위치로 (Setting Original Position)
엘리베이터가 2층에 있다면 다시 1층으로 내려온다. 1층에 있는 PhotoInterrupter가 엘리베이터를 인식하면 멈춘다.
If the elevator is at 2nd floor, it comes down to the 1st floor again. When the elevator reach 1st floor, photo interruptor recognizes the elevator, then elevator stops.
CODE Explanation_
else if (action == 16) {
//Motor down
Serial.println("Motor down");
digitalWrite(RED_LED_PIN, LOW);
digitalWrite(GREEN_LED_PIN, HIGH);
digitalWrite(BLUE_LED_PIN, HIGH);
StartMotorB(BACKWARD);
action = 17;
} else if (action == 17) {
if (digitalRead(PhotoInterrupter2_pin) == HIGH) {
Serial.println("Motor down end");
StopMotorB();
delay(500);
action = 0;
}
엘리베이터를 올리는 코드랑 비슷하다.
It's similar to the code that makes the elevator to go up.
재밌게 보셨다면 좋아요와 구독 그리고 댓글 부탁합니다 :D
Thank you for reading our project!
By 서울과학고 31기 백우준, 신해인, 이준상, 조경아
Thanks to 박다솜T
Comments