制造商零件编号 K001
ESP32 BASIC CORE IOT DEV KIT
M5Stack Technology Co., Ltd.
所订产品一般在 7-10个工作日 内送达中国,具体时间取决于收货地点。
最低订购金额为人民币 300 元,顺丰快递免运费配送。
当用人民币下单时,按照国际贸易条款 DDP(DigiKey 支付关税、海关费用和当地税款)方式结算。
电汇预付
更多来自全授权合作伙伴的产品
下单后,从合作伙伴发货平均需要时间 1-3 天,也可能产生额外运费。可能另外收取运费。 实际发货时间请留意产品详情页、购物车和结账页面上的说明。
国际贸易结算方式:CPT(交货时支付关税、海关费用和适用 VAT/应付税金)
有关详情,请访问帮助和支持
License: General Public License Arduino
* Thanks for the source code and project information provided by @BB Korry
This product is a table clock being developed for display at Japanese electronic craft exhibitions.
I wanted many visitors to forget the time and enjoy it at this exhibition, and as a result, I came up with the concept of "a clock that melts time just by looking at it."
This clock consists of 14 servomotors and the same number of disks as the servomotors.
Red and green segments are drawn on the disk. Then, these disks are rotated accurately by controlling the angle of the servo motor.
With this control, a digital display such as a 7-segment LED is displayed only by rotation.
↓↓↓See the Twitter URL below for a moving video↓↓↓
https://twitter.com/BitBlt_Korry/status/1411293739625041929?s=20
Custom parts and enclosures
Schematics
Code
谢谢!
敬请关注收件箱中的 DigiKey 新闻与更新!
请输入电子邮件地址
from m5stack import *
from m5ui import *
from uiflow import *
import time
import module
import math
#Initial variable / constant declaration
ms_count = 1000 #[Constant] 1 second clock adjustment time (reference 1000 msec)
ub_deg = 30 #[Constant] Adjustment angle (°) when displaying one side of the upper and lower disks
t_mode_time = 8 #[Constant] Effective time of temporary time display (sec)
h_disp_time = 2 #[Constant] Display time of "hour" (sec)
m_disp_time = 2 #[Constant] Display time of "minute" (sec)
seg_red = -1 #[Constant] 7-segment display color (red)
seg_blue = 1 #[Constant] 7-segment display color (blue)
seg_none = 0 #[Constant] 7-segment display color (no display)
motion_stop = 50 #[Constant] Wait time until the next axis operation of the servo
s0_aj = 0 #[Constant] Servo axis correction angle
s1_aj = -6 #[Constant] Servo axis correction angle
s2_aj = 0 #[Constant] Servo axis correction angle
s3_aj = -3 #[Constant] Servo axis correction angle
s4_aj = -6 #[Constant] Servo axis correction angle
s5_aj = 0 #[Constant] Servo axis correction angle
s6_aj = 0 #[Constant] Servo axis correction angle
s7_aj = 0 #[Constant] Servo axis correction angle
s8_aj = 0 #[Constant] Servo axis correction angle
s9_aj = -6 #[Constant] Servo axis correction angle
s10_aj = -5 #[Constant] Servo axis correction angle
s11_aj = 0 #[Constant] Servo axis correction angle
s12_aj = -15 #[Constant] Servo axis correction angle
s13_aj = 0 #[Constant] Servo axis correction angle
setting_flug = 1 # Configuration mode (0: No / 1: Yes)
t_mode_flug = 0 # Time displayed temporarily (0: No / 1: Yes)
mh_disp_flug = 0 #"hour" or "minute" displayed (0: No / 1 ~: Yes)
disp_stop = 0 # Screen operation stopped (0: No / 1: Yes)
setting_code = 1 # Setting mode selection (0: mode end confirmation / 1: hour 10 digits / 2: hour 1 digit / 3: minute 10 digits / 4: minute 1 digit / 5: second 10 digits / 6: second 1 digit)
m5_timer = 0 #M5 uptime
s1 = 0 #Current value of the ones digit of "second"
s10 = 0 #Current value of the tens digit of "second"
m1 = 0 #Current value of the ones digit of "minute"
m10 = 0 #Current value of the tens digit of "minute"
h1 = 2 #Current value of the ones digit of "hour"
h10 = 1 #Current value of the tens digit of "hour"
r0 = 0 #Right 7-segment (top) (0:OFF/1:ON)
r1 = 0 #Right 7-segment (upper left) (0:OFF/1:ON)
r2 = 0 #Right 7-segment (upper right) (0:OFF/1:ON)
r3 = 0 #Right 7-segment (center) (0:OFF/1:ON)
r4 = 0 #Right 7-segment (lower left) (0:OFF/1:ON)
r5 = 0 #Right 7-segment (lower right) (0:OFF/1:ON)
r6 = 0 #Right 7-segment (bottom) (0:OFF/1:ON)
l0 = 0 #Left 7-segment (top) (0:OFF/1:ON)
l1 = 0 #Left 7-segment (upper left) (0:OFF/1:ON)
l2 = 0 #Left 7-segment (upper right) (0:OFF/1:ON)
l3 = 0 #Left 7-segment (center) (0:OFF/1:ON)
l4 = 0 #Left 7-segment (lower left) (0:OFF/1:ON)
l5 = 0 #Left 7-segment (lower right) (0:OFF/1:ON)
l6 = 0 #Left 7-segment (bottom) (0:OFF/1:ON)
sn0 = 0 #Current state of servo 0
sn1 = 0 #Current state of servo 1
sn2 = 0 #Current state of servo 2
sn3 = 0 #Current state of servo 3
sn4 = 0 #Current state of servo 4
sn5 = 0 #Current state of servo 5
sn6 = 0 #Current state of servo 6
sn7 = 0 #Current state of servo 7
sn8 = 0 #Current state of servo 8
sn9 = 0 #Current state of servo 9
sn10 = 0 #Current state of servo 10
sn11 = 0 #Current state of servo 11
sn12 = 0 #Current state of servo 12
sn13 = 0 #Current state of servo 13
#Servo initial setting
servo = module.get(module.SERVO)
pwm12 = machine.PWM(machine.Pin(2))
pwm12.freq(50)
pwm13 = machine.PWM(machine.Pin(5))
pwm13.freq(50)
#Screen initial settings
setScreenColor(0x000000)
title0 = M5Title(title="mode:setting", x=3, fgcolor=0xFFFFFF, bgcolor=0x0000ff)
label0 = M5TextBox(95, 70, ":", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label1 = M5TextBox(30, 70, "1", lcd.FONT_DejaVu40, 0x0000ff, rotate=0)
label2 = M5TextBox(60, 70, "2", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label3 = M5TextBox(130, 70, "0", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label4 = M5TextBox(160, 70, "0", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label5 = M5TextBox(230, 70, "0", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label6 = M5TextBox(260, 70, "0", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label7 = M5TextBox(50, 110, "next", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label8 = M5TextBox(140, 110, "down", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label9 = M5TextBox(242, 110, "up", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label10 = M5TextBox(195, 70, ":", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
#Operation when button A is pressed
def buttonA_wasPressed():
global setting_flug, setting_code
#When not in setting mode: Switch to setting mode
if setting_flug == 0:
if disp_stop == 0:
if t_mode_flug == 0:
setting_flug = 1
setting_code = 1
#In setting mode: Send setting items
else:
if setting_code >= 6:
setting_code = 0
else:
setting_code += 1
#Screen update
screen_refresh()
btnA.wasPressed(buttonA_wasPressed)
#Operation when button B is pressed
def buttonB_wasPressed():
global setting_flug,t_mode_flug,s1,s10,m1,m10,h1,h10
#When not in setting mode: Temporary time display
if setting_flug == 0:
if disp_stop == 0:
if t_mode_flug == 0:
t_mode_flug = 1
#In setting mode: Minus the setting item (or end the setting)
else:
if setting_code == 0:
setting_flug = 0
elif setting_code == 1:
if h10 <= 0:
h10 = 2
else:
h10 -= 1
if h10 == 2:
if h1 >= 4:
h1 = 3
elif setting_code == 2:
if h10 == 2:
if h1 <= 0:
h1 = 3
else:
h1 -= 1
else:
if h1 <= 0:
h1 = 9
else:
h1 -= 1
elif setting_code == 3:
if m10 <= 0:
m10 = 5
else:
m10 -= 1
elif setting_code == 4:
if m1 <= 0:
m1 = 9
else:
m1 -= 1
elif setting_code == 5:
if s10 <= 0:
s10 = 5
else:
s10 -= 1
elif setting_code == 6:
if s1 <= 0:
s1 = 9
else:
s1 -= 1
#Screen update
screen_refresh()
btnB.wasPressed(buttonB_wasPressed)
#Operation when button C is pressed
def buttonC_wasPressed():
global setting_flug,disp_stop,s1,s10,m1,m10,h1,h10
#When not in setting mode: Return to origin and pause the time display
if setting_flug == 0:
if disp_stop == 0:
if t_mode_flug == 0:
disp_stop = 1
servo_move(seg_none)
else:
disp_stop = 0
#In setting mode: Add setting items (or finish setting)
else:
if setting_code == 0:
setting_flug = 0
elif setting_code == 1:
if h10 >= 2:
h10 = 0
else:
h10 += 1
if h10 == 2:
if h1 >= 4:
h1 = 3
elif setting_code == 2:
if h10 == 2:
if h1 >= 3:
h1 = 0
else:
h1 += 1
else:
if h1 >= 9:
h1 = 0
else:
h1 += 1
elif setting_code == 3:
if m10 >= 5:
m10 = 0
else:
m10 += 1
elif setting_code == 4:
if m1 >= 9:
m1 = 0
else:
m1 += 1
elif setting_code == 5:
if s10 >= 5:
s10 = 0
else:
s10 += 1
elif setting_code == 6:
if s1 >= 9:
s1 = 0
else:
s1 += 1
#Screen update
screen_refresh()
btnC.wasPressed(buttonC_wasPressed)
#Timer count event
def tmr1sec():
global mh_disp_flug,t_mode_flug,s1,s10,m1,m10,h1,h10
#"Hour" "Minute" is displayed and the remaining time is calculated
if mh_disp_flug != 0:
mh_disp_flug += 1
if mh_disp_flug >= 1 + h_disp_time + m_disp_time + 1:
mh_disp_flug = 0
#When a temporary time display is requested, set the "hour" and "minute" display flags
if t_mode_flug == 1:
mh_disp_flug = 1
#Calculation of remaining time in temporary time display
if t_mode_flug != 0:
t_mode_flug += 1
if t_mode_flug >= 1 + t_mode_time:
t_mode_flug = 0
#If not set, advance the time by 1 second
if setting_flug == 0:
s1 += 1
#Time display carry calculation
if s1 >= 10:
s1 = 0
s10 += 1
if s10 >= 6:
if setting_flug == 0:
if t_mode_flug == 0:
if disp_stop == 0:
mh_disp_flug = 1
s10 = 0
m1 += 1
if m1 >= 10:
m1 = 0
m10 += 1
if m10 >= 6:
if t_mode_flug == 0:
if disp_stop == 0:
mh_disp_flug = -1
m10 = 0
h1 += 1
if h10 <= 1:
if h1 >= 10:
h1 = 0
h10 += 1
else:
if h1 >= 5:
h1 = 0
h10 =0
#Move the servo if it is not in the paused state
if disp_stop == 0:
#"Seconds" are displayed in red unless "hours" and "minutes" are displayed.
if mh_disp_flug == 0:
r_set(s1)
l_set(s10)
servo_move(seg_red)
#1 When 1 hour has passed, a special display is displayed.
elif mh_disp_flug == -1:
m5_timer = time.ticks_ms()
r_set(8)
l_set(8)
servo_move(seg_none)
wait_ms(100)
servo_move(seg_red)
wait_ms(100)
servo_move(seg_blue)
wait_ms(100)
servo_move(seg_red)
wait_ms(100)
servo_move(seg_none)
wait_ms(400)
r_set(h1)
l_set(h10)
servo_move(seg_blue)
wait_ms(400)
servo_move(seg_none)
wait_ms(400)
servo_move(seg_blue)
wait_ms(400)
servo_move(seg_none)
wait_ms(400)
servo_move(seg_blue)
wait_ms(1800)
if time.ticks_ms() - m5_timer >= 1000:
s1 += math.floor((time.ticks_ms() - m5_timer) / 1000)
#"Hour" is displayed in blue immediately after the "hour" and "minute" display starts.
elif mh_disp_flug == 1:
r_set(h1)
l_set(h10)
servo_move(seg_blue)
#"Hour" is not displayed after the display time ends
elif mh_disp_flug == 1 + h_disp_time:
r_set(0)
l_set(0)
servo_move(seg_none)
#Finally, "minutes" are displayed in blue
elif mh_disp_flug == 1 + h_disp_time + 1:
r_set(m1)
l_set(m10)
servo_move(seg_blue)
#Right 7-segment display setting
def r_set(num):
global r0,r1,r2,r3,r4,r5,r6
if num == 1:
r0 = 0
r1 = 0
r2 = 1
r3 = 0
r4 = 0
r5 = 1
r6 = 0
elif num == 2:
r0 = 1
r1 = 0
r2 = 1
r3 = 1
r4 = 1
r5 = 0
r6 = 1
elif num == 3:
r0 = 1
r1 = 0
r2 = 1
r3 = 1
r4 = 0
r5 = 1
r6 = 1
elif num == 4:
r0 = 0
r1 = 1
r2 = 1
r3 = 1
r4 = 0
r5 = 1
r6 = 0
elif num == 5:
r0 = 1
r1 = 1
r2 = 0
r3 = 1
r4 = 0
r5 = 1
r6 = 1
elif num == 6:
r0 = 1
r1 = 1
r2 = 0
r3 = 1
r4 = 1
r5 = 1
r6 = 1
elif num == 7:
r0 = 1
r1 = 0
r2 = 1
r3 = 0
r4 = 0
r5 = 1
r6 = 0
elif num == 8:
r0 = 1
r1 = 1
r2 = 1
r3 = 1
r4 = 1
r5 = 1
r6 = 1
elif num == 9:
r0 = 1
r1 = 1
r2 = 1
r3 = 1
r4 = 0
r5 = 1
r6 = 1
elif num == 0:
r0 = 1
r1 = 1
r2 = 1
r3 = 0
r4 = 1
r5 = 1
r6 = 1
#Left 7-segment display setting
def l_set(num):
global l0,l1,l2,l3,l4,l5,l6
if num == 1:
l0 = 0
l1 = 0
l2 = 1
l3 = 0
l4 = 0
l5 = 1
l6 = 0
elif num == 2:
l0 = 1
l1 = 0
l2 = 1
l3 = 1
l4 = 1
l5 = 0
l6 = 1
elif num == 3:
l0 = 1
l1 = 0
l2 = 1
l3 = 1
l4 = 0
l5 = 1
l6 = 1
elif num == 4:
l0 = 0
l1 = 1
l2 = 1
l3 = 1
l4 = 0
l5 = 1
l6 = 0
elif num == 5:
l0 = 1
l1 = 1
l2 = 0
l3 = 1
l4 = 0
l5 = 1
l6 = 1
elif num == 6:
l0 = 1
l1 = 1
l2 = 0
l3 = 1
l4 = 1
l5 = 1
l6 = 1
elif num == 7:
l0 = 1
l1 = 0
l2 = 1
l3 = 0
l4 = 0
l5 = 1
l6 = 0
elif num == 8:
l0 = 1
l1 = 1
l2 = 1
l3 = 1
l4 = 1
l5 = 1
l6 = 1
elif num == 9:
l0 = 1
l1 = 1
l2 = 1
l3 = 1
l4 = 0
l5 = 1
l6 = 1
elif num == 0:
l0 = 1
l1 = 1
l2 = 1
l3 = 0
l4 = 1
l5 = 1
l6 = 1
#Servo operation
def servo_move(color):
global sn0,sn1,sn2,sn3,sn4,sn5,sn6,sn7,sn8,sn9,sn10,sn11,sn12,sn13,pwm12,pwm13
#Movement from the current angle to each arrangement
if r0 * color != sn0:
servo.write_angle(0, 90 + r0 * color * 90 + (1 - r0 * color^2)*s0_aj)
wait_ms(motion_stop)
sn0 = r0 * color
if r1 * color != sn1:
servo.write_angle(1, 90 + r1 * color * 90 + (1 - r1 * color^2)*s1_aj)
wait_ms(motion_stop)
sn1 = r1 * color
if r2 * color != sn2:
servo.write_angle(2, 90 + r2 * color * 90 + (1 - r2 * color^2)*s2_aj)
wait_ms(motion_stop)
sn2 = r2 * color
if r3 * color != sn3:
servo.write_angle(3, 90 + r3 * color * 90 + (1 - r3 * color^2)*s3_aj)
wait_ms(motion_stop)
sn3 = r3 * color
if r4 * color != sn4:
servo.write_angle(4, 90 + r4 * color * 90 + (1 - r4 * color^2)*s4_aj)
wait_ms(motion_stop)
sn4 = r4 * color
if r5 * color != sn5:
servo.write_angle(5, 90 + r5 * color * 90 + (1 - r5 * color^2)*s5_aj)
wait_ms(motion_stop)
sn5 = r5 * color
if r6 * color != sn6:
servo.write_angle(6, 90 + r6 * color * 90 + (1 - r6 * color^2)*s6_aj)
wait_ms(motion_stop)
sn6 = r6 * color
if l0 * color != sn7:
servo.write_angle(7, 90 + l0 * color * 90 + (1 - l0 * color^2)*s7_aj)
wait_ms(motion_stop)
sn7 = l0 * color
if l1 * color != sn8:
servo.write_angle(8, 90 + l1 * color * 90 + (1 - l1 * color^2)*s8_aj)
wait_ms(motion_stop)
sn8 = l1 * color
if l2 * color != sn9:
servo.write_angle(9, 90 + l2 * color * 90 + (1 - l2 * color^2)*s9_aj)
wait_ms(motion_stop)
sn9 = l2 * color
if l3 * color != sn10:
servo.write_angle(10, 90 + l3 * color * 90 + (1 - l3 * color^2)*s10_aj)
wait_ms(motion_stop)
sn10 = l3 * color
if l4 * color != sn11:
servo.write_angle(11, 90 + l4 * color * 90 + (1 - l4 * color^2)*s11_aj)
wait_ms(motion_stop)
sn11 = l4 * color
if l5 * color != sn12:
l5calc = 90 + l5 * color * 90 +(1 - l5* color^2)*s12_aj
pwm12.duty(2.7 + l5calc/19.35)
wait_ms(motion_stop)
sn12 = l5 * color
if l6 * color != sn13:
l6calc = 90 + l6 * color * 90 +(1 - l6 * color^2)*s13_aj
pwm13.duty(2.7 + l6calc/19.35)
wait_ms(motion_stop)
sn13 = l6 * color
#Screen update
def screen_refresh():
#Time character display
label1.setText(str(h10))
label2.setText(str(h1))
label3.setText(str(m10))
label4.setText(str(m1))
label5.setText(str(s10))
label6.setText(str(s1))
#Title character display / color display
if setting_flug == 1:
title0.setTitle('mode:setting')
title0.setBgColor(0x0000ff)
elif disp_stop == 1:
title0.setTitle('mode:stop')
title0.setBgColor(0x606060)
elif mh_disp_flug >= 1:
title0.setTitle('mode:H/M disp')
title0.setBgColor(0x008000)
else:
title0.setTitle('mode:S disp')
title0.setBgColor(0xff0000)
#Button function display
if setting_flug == 1:
if setting_code == 0:
label7.setText('next')
label8.setText('-')
label9.setText('end')
else:
label7.setText('next')
label8.setText('down')
label9.setText('up')
else:
label7.setText('Set')
label8.setText('M/H')
label9.setText('Stop')
#Time color display
if setting_flug == 1:
if setting_code == 0:
label1.setColor(0x0000ff)
label2.setColor(0x0000ff)
label3.setColor(0x0000ff)
label4.setColor(0x0000ff)
label5.setColor(0x0000ff)
label6.setColor(0x0000ff)
elif setting_code == 1:
label1.setColor(0x0000ff)
label2.setColor(0xffffff)
label3.setColor(0xffffff)
label4.setColor(0xffffff)
label5.setColor(0xffffff)
label6.setColor(0xffffff)
elif setting_code == 2:
label1.setColor(0xffffff)
label2.setColor(0x0000ff)
label3.setColor(0xffffff)
label4.setColor(0xffffff)
label5.setColor(0xffffff)
label6.setColor(0xffffff)
elif setting_code == 3:
label1.setColor(0xffffff)
label2.setColor(0xffffff)
label3.setColor(0x0000ff)
label4.setColor(0xffffff)
label5.setColor(0xffffff)
label6.setColor(0xffffff)
elif setting_code == 4:
label1.setColor(0xffffff)
label2.setColor(0xffffff)
label3.setColor(0xffffff)
label4.setColor(0x0000ff)
label5.setColor(0xffffff)
label6.setColor(0xffffff)
elif setting_code == 5:
label1.setColor(0xffffff)
label2.setColor(0xffffff)
label3.setColor(0xffffff)
label4.setColor(0xffffff)
label5.setColor(0x0000ff)
label6.setColor(0xffffff)
elif setting_code == 6:
label1.setColor(0xffffff)
label2.setColor(0xffffff)
label3.setColor(0xffffff)
label4.setColor(0xffffff)
label5.setColor(0xffffff)
label6.setColor(0x0000ff)
elif disp_stop == 1:
label1.setColor(0x606060)
label2.setColor(0x606060)
label3.setColor(0x606060)
label4.setColor(0x606060)
label5.setColor(0x606060)
label6.setColor(0x606060)
elif mh_disp_flug >= 1:
if mh_disp_flug >= 1 + h_disp_time:
label1.setColor(0xffffff)
label2.setColor(0xffffff)
label3.setColor(0x00ff00)
label4.setColor(0x00ff00)
label5.setColor(0xffffff)
label6.setColor(0xffffff)
else:
label1.setColor(0x00ff00)
label2.setColor(0x00ff00)
label3.setColor(0xffffff)
label4.setColor(0xffffff)
label5.setColor(0xffffff)
label6.setColor(0xffffff)
else:
label1.setColor(0xffffff)
label2.setColor(0xffffff)
label3.setColor(0xffffff)
label4.setColor(0xffffff)
label5.setColor(0xff0000)
label6.setColor(0xff0000)
#Timer operation
while True:
if (time.ticks_ms()) >= m5_timer + ms_count :
m5_timer = time.ticks_ms()
tmr1sec()
screen_refresh()
wait_ms(2)