The Arduino KNN library offers a way to include some simple machine learning into your Arduino sketch quickly and easily.
Here's a quick project created to test how fast the color sensor sampling and inferencing can work (it turns out fast enough to classify candy in free fall!). One major difference between this sketch and the example color classifier in the library is it does not use proximity to detect objects, but instead checks for variations in light level - making it suitable for use in our tube.
With an Arduino Nano BLE Sense, some paper, scissors, tape and a bag of candy, you are able to create an M&M color classifier using TinyML.
ConstructionThis requires some paper, scissors and tape:
- Create a paper tube just bigger than the candy that has to pass through
- Cut a small window enough for the LEDs and sensor on the BLE Sense board
- Tape the Arduino to the paper tube
- Create a cone for the top so you can throw candy in there
Run the sketch and throw candy into the hopper. The positioning of the board and controlling the lighting conditions have a big impact on accuracy. I found a darkened room to be better (but not so dark you can't see where to throw the candy).
Emojis for Linux terminal outputYou can use emojis for the object names in your sketch. In Linux it's then easy to view the serial output from your Arduino so you can see a log of what candy it saw for verification purposes.
Enjoy!
Comments