Parking Alarm

Parking Alarm

per Citilab Edutec

Boards
Plaques:

Citilab ED1

Component/s
Components:

Distància (VL53L0X)
This activity is part of the Citilab Course. Check it out!

Parking Alarm

Distance sensor VL53L0X

  • In this example we will work with a distance sensor, with a measurement range between 2 and 50 cm.

  • This is a sensor that measures the time it takes for a laser to bounce off the surface to be measured (Time of Flight TOF).

  • It is a digital sensor, and it is connected via the I²C serial bus. The I²C connection needs 4 cables, two for power and two for sending and receiving signals.

VL53L0X distance sensor

Distance sensor connection (I²C)

  • The sensor has a Groove connector and an adapter is needed for the ED1.

  • Black corresponds to GND (Ground).

  • The red corresponds to the 5V (it is important not to cross the GND and the 5V as the sensor or the board can be damaged.

  • The other connections are represented with white and yellow colors. In the case of the adapters indicated, the white goes to the SDA connector of the ED1 and the yellow to the SDL connector (they are crossed in relation to the colors drawn on the sensor).

Grove Connector ED1 I²C Pins
Dupont-Grove Cables Connection with ED1

VL53L0X library

  • The library for this sensor is in the Sensing category with the name VL53L0X.

VL53L0X library

  • Just add 2 blocks one that returns the distance in millimeters and another that tells us if the sensor is connected.

VL53L0X blocks

Challenge 1: Make a program that displays the distance in mm per screen

Challenge

Solution to challenge 1

Tone Library

  • MicroBlocks incorporates a library for cards that support the generation of sounds. This is the Tone library. In the case of the ED1, it is loaded automatically.

Tone library blocks

  • The basic block is play frequency _ for _ ms which plays for the specified time, a tone at the specified frequency.

Tone frequency block

  • The values ​​that the ED1 mini speaker can reproduce are between 100 and 10,000 Hz. The maximums perceptible by the human ear are between 20-20,000 Hz.

Play notes with the ED1

  • The block play the note _ in the octave _ for _ ms allows you to play musical notes in both Anglo-Saxon and European notation.
Anglo-saxon notation European notation

Notes Notation

  • In the Music folder of the examples, you can find several projects that play melodies.

  • The Ringtone library allows you to play melodies in RTTTL format from Nokia. Examples 1 2.

Parking sensor

  • The reverse parking sensors measure the distance and generate visual and acoustic signals to warn of the proximity of an obstacle.

Traffic Light

  • Our sensor does not detect very short or very long distances (2-100 cm) and therefore we will have to take this into account in our code.

  • We can define multiple conditions with _ and and or _ operators.

Distance blocks

Challenge 2: Make a visual and audible parking sensor

Challenge

Solution to challenge 2

CC-BY-SA

© per Citilab Edutec 2019-2022.
Aquesta obra té una llicència CC-BY-SA 4.0.