Friday, September 23, 2022

Making a shake alarm - Movement sensor with radio

What to know if something it´s being moved with a control remote? Then you can use this code. Both micro:bits will have the same code, when the micro:bit it’s moved then an alarm will sound, and an angry face will appear in both micro:bits:


This code uses a FUNCTION (it’s a set of commands that you add, you will find it under the ADVANCE section and FUNCTION). If you do not want to use this function but want to have the same result, you can do this:


Now, If you want to have two independent micro:bit, one that can send you a signal every time it’s moved ut you don’t want to have any sound or light on that micro:bit (for example, you don’t want to warn the thief if he has move the object, or you are tracing an animal and do not want to disturb it) and the other micro:bit would be a control remote in a different place and has a sound alarm, you will need to codes:

Code for sender:


Code for receiver:



Sunday, April 24, 2022

Draw Turkey flag with python turtle

 Code:



from turtle import*

setup(800,500)

speed(5)

penup()

goto(-400, 250)

pendown()

 

color("red")

begin_fill()

for n in range(2):

    forward(800)

    right(90)

    forward(500)

    right(90)

end_fill()

 

penup()

goto(-50, 0)

 

penup()

backward(75)

left(90)

forward(125)

left(90)

pendown()

 

color("white")

begin_fill()

circle(127.5)

end_fill()

 

penup()

goto(-87, 105.5)

pendown()

 

color("red")

begin_fill()

circle(107)

end_fill()

 

penup()

color("white")

goto(50, -35)

right(20)

begin_fill()

for x in range(5):

    forward(100)

    right(144)

end_fill()

 

penup()

goto(350, -255)

right(154)

color("white")


Create pictures with the CHAR function in Google Sheets

Saturday, April 16, 2022

ESP32 Capacitive Touch Sensor Pins with microPython | Touch Sensitive LED

The ESP32 provides up to 10 capacitive sensing GPIOs.
These GPIOs can detect variations in anything that contains an electrical charge, such as human skin. They can thus detect the variations induced when touching the GPIOs with a finger.

Comment utiliser les broches tactiles ESP32 avec MicroPython?


Code1:
from machine import Pin, TouchPad
from time import sleep

touch=TouchPad(Pin(4))
while True:
    print(touch.read())
    sleep(0.5)
    
Code2:
from machine import Pin, TouchPad
from time import sleep

touch=TouchPad(Pin(4))
led=Pin(16,Pin.OUT)

touch.config(300)

while True:
    if touch.read()<=300:
        led.value(not led.value())
    sleep(0.5)