Page 72 - 최강 아두이노 스마트 자동차 로봇 키트
P. 72
else if(direction == BACKWARD) // 후진.
{
digitalWrite(EN1, HIGH);
digitalWrite(EN2, LOW);
analogWrite(ENA, speed);
digitalWrite(EN3, HIGH);
digitalWrite(EN4, LOW);
analogWrite(ENB, speed);
}
else if(direction == LEFT) // 좌회전
{
digitalWrite(EN1, HIGH);
digitalWrite(EN2, LOW);
analogWrite(ENA, speed);
digitalWrite(EN3, LOW);
digitalWrite(EN4, HIGH);
analogWrite(ENB, speed);
}
else if(direction == RIGHT) // 우회전
{
digitalWrite(EN1, LOW);
digitalWrite(EN2, HIGH);
analogWrite(ENA, speed);
digitalWrite(EN3, HIGH);
digitalWrite(EN4, LOW);
analogWrite(ENB, speed);
}
else if(direction == STOP) // 정지.
{
analogWrite(ENA, 0);
71