티스토리 뷰

#define CW HIGH
#define CCW LOW

void setup()  {
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
}

void loop()  {
  int motorSpeed = analogRead(A0) / 4;
  setMotor(motorSpeed, CW);
  delay(2000);
  setMotorStop();
  delay(2000);
  setMotor(motorSpeed, CCW);
  delay(2000);
  setMotorStop();
  delay(2000);
}

void setMotor(int motorSpeed, boolean motirDir)  {
  analogWrite(9, motorSpeed);
  digitalWrite(8, motirDir);
  digitalWrite(7, !motirDir);
}

void setMotorStop()  {
  digitalWrite(8, CCW);
  digitalWrite(7, CCW);
}


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
TAG
more
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함