Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Emelin
Published © MIT

M5Stack Christmas Santa detector

Do you want to know when Santa Claus arrives without scaring the reindeer? It also works with the Wise Men!

BeginnerFull instructions provided30 minutes4,937

Things used in this project

Hardware components

M5Stack Core2 ESP32 IoT Development Kit
×1
M5Stack Goplus2 DC Motor and Servo Driver Module (STM32F0)
×1
M5Stack PIR Motion Sensor (AS312)
×1
M5Stack Servo Kit 360° LEGO-compatible
×1
Beard Ornaments
×1

Software apps and online services

M5Stack uiFlow

Story

Read more

Schematics

Schematics

Be careful removing the back part of the Core2. The screws have different sizes. Make a picture of its place in case you want to mount the cover back again. And be gentle with the cable of the battery.

Code for direct upload to Core2 via "open"

https://flow.m5stack.com/

Code

JingleServoBells

Python
Just upload it to the Core2 via uiFlow (online or offline). Paste it in the "</>Python" label -in the center of the page- ---> https://flow.m5stack.com/
from m5stack import *
from m5stack_ui import *
from uiflow import *
import module

import time
import unit

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xfb0101)
pir0 = unit.get(unit.PIR, unit.PORTA)


A = None
B = None
D = None
C = None

go_plus_2 = module.get(module.GOPLUS2)
JingleServoBells = M5Btn(text='Bells!', x=60, y=20, w=200, h=200, bg_c=0x15ff00, text_c=0x000000, font=FONT_MONT_32, parent=None)



def JingleServoBells_pressed():
  global A, B, D, C
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, B)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, C)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, B)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, C)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, B)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, C)
  wait_ms(0)
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms((D * 2))
  go_plus_2.set_servo_plus(go_plus_2.S1, B)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, C)
  wait_ms((D * 4))
  go_plus_2.set_servo_plus(go_plus_2.S1, A)
  wait_ms(D)
  go_plus_2.set_servo_plus(go_plus_2.S1, C)
  pass
JingleServoBells.pressed(JingleServoBells_pressed)


A = 2000
B = 1000
C = 1500
D = 250
while True:
  if (pir0.state) == 1:
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, B)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, C)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, B)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, C)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, B)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, C)
    wait_ms(0)
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms((D * 2))
    go_plus_2.set_servo_plus(go_plus_2.S1, B)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, C)
    wait_ms((D * 4))
    go_plus_2.set_servo_plus(go_plus_2.S1, A)
    wait_ms(D)
    go_plus_2.set_servo_plus(go_plus_2.S1, C)
  wait_ms(2)

Credits

Emelin
1 project • 1 follower

Comments