some change to check crossload

This commit is contained in:
2025-12-10 02:50:49 +09:00
parent 387f483951
commit 52a8d07fe4

View File

@@ -40,8 +40,6 @@ int main() {
// 초기 안정화 대기
Clock_Delay1ms(500);
int align_phase = 0; // 0: 출발 라인 벗어나기, 1: 목표 라인 찾기
while(1) {
switch(current_state) {
case STATE_ALIGNING:
@@ -120,16 +118,9 @@ int main() {
// 3. 왼쪽 라인(검은색) 감지 시 정지
// 출발 직후(오른쪽 라인)에는 감지될 수 있으므로,
// 일단 흰색(0x00)이 된 후 다시 검은색이 나올 때 멈추는 로직 필요
static int left_line_phase = 0;
if (left_line_phase == 0) {
if (raw_val == 0x00) left_line_phase = 1; // 출발 라인 벗어남
} else if (left_line_phase == 1) {
if (raw_val != 0x00) { // 목표 라인 도착
motor_stop();
if (is_crossroad(raw_val)) {
current_state = STATE_STOP;
}
}
Clock_Delay1ms(PERIOD_MS);
}
break;