Seeeduino XIAO – Objects Detection

After the Arduino IDE environment  configuration for the Seeeduino XIAO board in the previous article

Seeeduino XIAO – Arduino Envinronment

in this we will make a small example with this card.

In the project we’ll use the following components

  1. Ultrasonic sensor HC-SR04
  2. I2C  Oled  Display 0,96 pollici SSD1306

The first step is to install the libraries of the two components listed above on Arduino.

In the Arduino IDE, go to the menu  Sketch->Include Library->Manage Libraries

addlib-enFor HCSR04 we choose HCSR04 by Martin Sosic

hcsr04-enFor SSD1306 we choose ACROBOTIC SSD1306

SSD1306-en

Now we have all the components for the project. We connect the components to the Seeeduino XIAO as listed in the following table

XIAO PINSSD1306 PINHCSR04 PIN
3V3VDD
GNDGNDGND
5VVCC
D2ECHO
D1TRIG
D5SCK
D4SDA

As can be seen from the table, we use the I2C and digital pins 1,2  of the XIAO

pinsexampleBelow is the connections diagram

xiaoconnectionsThe example code is the following

If an object passes through the sensor’s field of view, the event is signaled on the OLED screen with the recorded measurement. Inside the code there are the descriptions of all the operations performed.

Here is the link to the source code file

exampleXiao.ino