아두이노

감 깍는 모타

내동 2021. 10. 29. 05:03

#include "BTS7960.h"
const int buttonPin = 7; 

const uint8_t EN = 8;
const uint8_t L_PWM = 9;
const uint8_t R_PWM = 10;

BTS7960 motor(EN, L_PWM, R_PWM);

void setup() 
{Serial.begin(9600);
 pinMode(buttonPin, INPUT);
  }

void loop() {
  int reading = digitalRead(buttonPin);
     Serial.println(reading);
     if(reading == HIGH) { Push();}
    else{ motor.Disable(); }
             }

  
 void Push(){
  motor.Enable();
  motor.TurnRight(50);
delay(10000);
   motor.Stop();
   motor.Disable();
   delay(1000);}

'아두이노' 카테고리의 다른 글

세탁기 표시창  (0) 2022.01.25
RPM측정  (0) 2021.12.18
바운스 버턴  (0) 2021.10.15
Table Tennis  (0) 2021.08.17
Pid  (0) 2021.06.13