42 lines
1.0 KiB
Python
42 lines
1.0 KiB
Python
import time
|
|
import machine
|
|
import DS3231
|
|
import Button
|
|
import uasyncio as asyncio
|
|
import StepperL298M
|
|
import StepperClock
|
|
|
|
#Async
|
|
loop = asyncio.get_event_loop()
|
|
|
|
#Initialise the time module with the RTC
|
|
dsRtc = DS3231.DS3231(machine.I2C(sda = machine.Pin(17), scl=machine.Pin(18)))
|
|
rtc = machine.RTC()
|
|
rtc.init(dsRtc.DateTime()+[0])
|
|
|
|
#Initalise the Motors
|
|
stepperminu = StepperL298M.Stepper([19,21,22,23],inverted=False)
|
|
stepperhour = StepperL298M.Stepper([12,27,26,25],inverted=True)
|
|
clock = StepperClock.StepperClock(stepperhour,stepperminu)
|
|
|
|
|
|
LED = machine.Pin(32,machine.Pin.OUT)
|
|
|
|
def leftButtonClick():
|
|
global i
|
|
print("Down",LED.value())
|
|
LED.value(not LED.value())
|
|
stepperhour.rotateTo(stepperhour.getTarget()+0.1)
|
|
Button.Button(36,leftButtonClick,None,inverted=True)
|
|
|
|
def rightButtonClick():
|
|
global i
|
|
print("Down",LED.value())
|
|
LED.value(not LED.value())
|
|
stepperhour.rotateTo(stepperhour.getTarget()-0.2)
|
|
Button.Button(34,rightButtonClick,None,inverted=True)
|
|
|
|
clock.start()
|
|
|
|
loop.run_forever()
|