Project 2 update and an introduction to I2C. I2C is pretty straight forward especially when working with a break-out board form a manufacturer that has good support and most of all a good library to accompany the board.
Project 2 update and an introduction to I2C. I2C is pretty straight forward especially when working with a break-out board form a manufacturer that has good support and most of all a good library to accompany the board. For both the lab and part of Project 2 the Adafruit VL53L0X Time of Flight Distance Sensor was chosen. This small break-out board is easy to include in projects of all sizes due to it small for factor. The size and accuracy of this sensor is what lead to it being chosen for Project 2.
Project 2 must include some form of microcontroller-to-PC communication. We all sit in front of the computer, so of us for many many hours a day, and some of us sit in the same place for far too long. In concept, Project 2 hopes to address this behavior by using an Arduino Nano 33IoT, a few LED’s, the aforementioned VL53L0X Time of Flight Distance Sensor, and a few different code libraries-one being #keyboard.h
. The general flow is as follows:
- Set interval at which the user wants to disengage form computer use
- Green, Yellow, and Red LED’s will light at given periods to alert user that the interval is coming to an end.
- Once interval has elapsed, the Nano will send a sleep command to the PC, using the #keyboard.h library, to put the screen to sleep.
- The Nano will then look for a sensor reading form the VL53L0X to determine if the user has moved from in front of the computer.
- Once the distance reading of the sensor is greater than a given range the Nano will send a keyboard command of “SPACEBAR” to the PC which will in turn wake up the screen.
So far the individual code modules for each task work independently of each other. The next task is to combine the modules into a single sketch and test the functionality of the concept.
The biggest problem so far has been…WINDOWS!! Windows really doesn’t play nicely when accessing the COM ports and really hates when make a device that actually looks like two devices. Such as when you take a microcontroller, a Nano 33IoT, and make it a keyboard. This forces the PC to re-innumerate the serial devices shifting the Nano down on the port list to make a place for the new keyboard device created. This displays some odd behavior, when plugging in the Nano after the code has been flashed to the board, the screen shuts off immediately. This is not the intended behavior. Some adjustment to the code and possibly drivers will need to be investigated in order to sort this out.
The VL53L0X Time of Flight Distance Sensor on the other hand is a dream to work with, basically plug-and-play. The library is fairly easy to understand and make changes as need to accommodated different scenarios.
More to come in a future post.