import time
import machine
from machine import Pin
print("Hello, ESP32!")
pin_dir = Pin(2, Pin.OUT)
pin_step = Pin(4, Pin.OUT)
int jumlah_step = 200;
button = machine.Pin(25, machine.Pin.IN, machine.Pin.PULL_UP)
# if button pressed = 0 , if button not pressed 0
while True:
print("Motor State", button.value())
time.sleep(0.1)
if button.value() == 0 :
for(int n = 0; n < jumlah_step; n++) :
pin_dir.value(1)
pin_step.value(1)
time.sleep(0.5)
else :
for(int n = 0; n < jumlah_step; n++) :
pin_dir.value(0)
pin_step.value(0)
time.sleep(0.5)