Skip to main content
Version: ACS CC

Candy sorter

Sorts candies based on their colour.

info

Author: Sândulache Mihnea-Ștefan
GitHub Project Link: https://github.com/UPB-PMRust-Students/proiect-mihneasandulache

Description

A device which uses a colour sensor in order to sort candies based on their colours. The identified colour is then displayed on a LCD screen and a LED is turned on corresponding with the respective colour.

  • The system utilizes a sensor to identify colour of the candy.

  • A servomotor then rotates the candy above a pipe.

  • The pipe is rotated to a pre-calculated angle, based on the colour of the candy so it drops in a special glass.

  • The LCD screen showcases the colour of the candy.

  • An LED is then turned on based on the colour.

  • Both servomotors rotated back to their initial state and another candy is ready to be dropped.

Motivation

This project reflects my desire to dive deeper into embedded programming using a new language — Rust. I chose Rust for its performance and safety, and because it's becoming a strong player in the embedded world.

As a kid, I was fascinated by M&M’s candy dispensers and often imagined building one that could sort candies by flavour or color. That idea stuck with me and inspired this project.

While planning the system, from sensors to microcontrollers, I realized it’s more than just code. It’s also about designing and building the physical device, something that taps into my love for arts and crafts.

Architecture

The Raspberry Pi Pico 2W serves as the central control unit, directing and managing all other components utilized within the project.

The LCD serves as an interface for showcasing the colour of the candy, it is connected to the Pico through I2C

The servomotors are responsible for rotating the candy and the pipe, ensuring that the candy is dropped into the correct glass.

The LED lights up in the corresponding colour of the candy, providing a visual indication of the detected colour.

The colour sensor identifies the colour of the candy and sends the data to the Pico for processing.

The pipe is rotated to a pre-calculated angle based on the colour of the candy, ensuring it drops into the correct glass.

The two cardboard disks are used to create a makeshift arm, which is rotated by the servomotor. This arm is responsible for holding the candy and dropping it into the correct glass.

diagram

Log

Week 5 - 11 May

Week 12 - 18 May

Week 19 - 25 May

Hardware

  1. Raspberry Pi Pico 2W:
  • Purpose: Controls all components.
  • Function: Acts as the main controller, coordinating the operations of sensors, motors, buzzers, and the LCD display.
  1. Colour Sensor:
  • Purpose: Detects the colour of the candy.
  • Function: Identifies the colour of the candy and sends the data to the Raspberry Pi Pico for processing.
  1. LCD Display:
  • Purpose: Displays the detected colour of the candy.
  • Function: Provides a visual interface for the user, showing the colour of the candy detected by the sensor.
  1. Servomotor:
  • Purpose: Rotates the candy and the pipe.
  • Function: Controls the movement of the candy and the pipe, ensuring that the candy is dropped into the correct glass.
  1. LED:
  • Purpose: Provides a visual indication of the detected colour.
  • Function: Lights up in the corresponding colour of the candy, providing a visual indication of the detected colour.

Hardware Overview:

  • The Raspberry Pi Pico controls and coordinates all components.
  • The LCD displays the detected colour of the candy.
  • The servomotors rotate the candy and the pipe, ensuring that the candy is dropped into the correct glass.
  • The LED lights up in the corresponding colour of the candy.
  • The colour sensor identifies the colour of the candy and sends the data to the Pico for processing.

Schematics

diagram

Bill of Materials

DeviceUsagePrice
Rapspberry Pi Pico 2WThe microcontroller39,66 RON
TCS230Colour Sensor38,99 RON
LCD DisplayLCD Display14 RON
ServomotorServomotor14 RON

Software

LibraryDescriptionUsage
embassy-rpRP2350 PeripheralsUsed for accessing the peripherals
esp-idf-servoServo controlUsed for controlling the servomotor
embedded-halEmbedded Hardware Abstraction LayerUsed for accessing the hardware
ag-lcdLCD displayUsed for controlling the LCD display
cortex-mProvides low-level APIs for ARM Cortex-M processorsInterrupt handling and system control
embassy-executorAsynchronous executor for embedded systemsUsed for managing tasks and scheduling