This is an old revision of the document!


Sweet Sort

Introduction

Student: Iliescu Laura-Gabriela Group 1221A

Sweet Sort is an exciting Arduino project that allows you to build your own color candy sorting machine. With this machine, sorting large quantities of candies by color becomes a quick and easy process. This project is an excellent way to learn about Arduino programming and electronics while creating a fun and useful device.

As an Arduino enthusiast, I find this project to be both challenging and rewarding. Not only do you get to create a useful device, but you also gain a deeper understanding of Arduino programming and electronics. Building Sweet Sort is a great way to expand your skillset and showcase your creativity.

General Description

With just one TCS230 color sensor and two SG90 servomotors, you can easily sort candies based on their color. The machine operates by moving the candy from the main container to the sensor and then to its designated container based on its color. To make the sorting process even more seamless, the machine comes equipped with an LCD screen with I2C Interface that displays the color of each candy. Additionally, an auditory alert system in the form of a buzzer will notify you when a candy has been successfully sorted. The project also features RGB LEDs that illuminate to display the color of the candy.

Hardware Design

The list of components for this project includes:

  • Arduino UNO R3
  • TCS230 color sensor
  • 2 SG90 servo motors (180 degrees)
  • LCD 1602 with I2C interface module
  • Breadboard
  • Buzzer
  • Common cathode RGB LEDs
  • Wires

For the box I used a 2.5mm thick MDF board

Software Design

Mediu de dezvoltare: Arduino IDE

The code is an Arduino sketch that controls a candy sorting machine using a color sensor, servomotors, and an LCD display. Here's an explanation of the code:

Libraries: The code includes two libraries: Servo.h for controlling the servomotors and LiquidCrystal_I2C.h for interfacing with the LCD display.

Pin Definitions: Various pins are defined using the #define directive for easy reference throughout the code. These pins are used to connect the color sensor, servomotors, RGB LED, buzzer, and LCD display.

Global Variables: The code defines several global variables to store calibration values, pulse width measurements, and the number of candies sorted for each color.

Setup Function: The setup() function is executed once at the beginning of the program. It initializes the serial communication, attaches the servomotors, sets pin modes, initializes the LCD, and sets the initial position for the top servomotor.

Loop Function: The loop() function is executed repeatedly after the setup() function. It controls the main operation of the candy sorting machine. The loop consists of the following steps:

a. Removing Candies: The top servomotor rotates from position 10 to 100, causing the candies to fall out of the tube. The delay of 15 ms after each position change allows the servomotor to reach the desired position.

b. Color Sensing: The top servomotor rotates from the maximum position (TOP_MAX) to the minimum position (TOP_MIN) while checking the color of the candy in front of the color sensor. When the servomotor reaches the position (SENSOR_POS) in front of the color sensor, it stabilizes for 1 second and reads the pulse widths of the red, green, and blue components using the color sensor.

c. Color Classification: The pulse width values are compared with the calibrated minimum and maximum values for each color (red, green, and blue). If a candy matches the color criteria, the corresponding RGB LED values, sound tone, and position for the bottom servomotors are set, and the count for that color is incremented.

d. LCD Display: The LCD is updated with the count of candies for each color.

e. RGB LED Control: The RGB LED is controlled by analogWrite() function, setting the appropriate values for the red, green, and blue pins based on the color of the candy being sorted.

Helper Functions: The code includes several helper functions:

getRedPW(), getGreenPW(), getBluePW(): These functions configure the color sensor to read the pulse width of a specific color (red, green, or blue) and return the measured pulse width value.

playTone(unsigned int frequency, unsigned long duration): This function plays a tone on the connected buzzer for a specific frequency and duration.

The code continuously repeats the loop, allowing the candy sorting machine to sort candies based on their colors and display the count on the LCD.

Rezultate Obţinute

Care au fost rezultatele obţinute în urma realizării proiectului vostru.

Concluzii

Download

O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectului: surse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-).

Fişierele se încarcă pe wiki folosind facilitatea Add Images or other files. Namespace-ul în care se încarcă fişierele este de tipul :pm:prj20??:c? sau :pm:prj20??:c?:nume_student (dacă este cazul). Exemplu: Dumitru Alin, 331CC → :pm:prj2009:cc:dumitru_alin.

Jurnal

Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului.

Bibliografie/Resurse

Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe Resurse Software şi Resurse Hardware.

Export to PDF

pm/prj2023/apredescu/sweetsort.1685304755.txt.gz · Last modified: 2023/05/28 23:12 by laura.iliescu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0