
This project simulates a vending machine that dispenses colored balls in three colors. The user picks a ball color by inserting a token of that same color. The design works as a finite state machine (FSM) with these steps:
Token insertion: The machine waits for a token to be inserted. Color detection: A color sensor identifies the token as one of the three colors. Dispensing: The FSM turns on the motor for that color, which releases a ball. Ball ready: A second sensor detects that the ball has reached the pickup tray. Pickup: After the user removes the ball, the machine goes back to the idle state and waits for the next token.
Reset the design and check that the machine starts in the idle state. Simulate inserting a token by setting the token-detect input. Set the color inputs to choose one of the three colors, and check that the matching motor output turns on. Activate the "ball ready" sensor input and check that the motor turns off and the ready indicator turns on. Simulate pickup by clearing the sensor input, and check that the machine goes back to idle. Repeat with the other two colors to confirm that each one drives the correct motor.
Color sensor: detects the color of the inserted token (for example, a TCS3200/TCS34725 module or three photodiodes with RGB filters). Token sensor: detects that a token was inserted (IR sensor or limit switch). 3 motors: one per ball color, driven through a motor driver (for example, an L293D or ULN2003), since the chip outputs can't power motors directly. Ball-ready sensor: an IR or optical sensor in the pickup tray that detects when the ball is ready to collect.
| # | Input | Output | Bidirectional |
|---|---|---|---|
| 0 | sensor_entrada | paso_pin1 | ocupado2 |
| 1 | sensor_salida | paso_pin2 | ocupado3 |
| 2 | dir_entrada | paso_pin3 | |
| 3 | color[0] | dir_pin1 | |
| 4 | color[1] | dir_pin2 | |
| 5 | dir_pin3 | ||
| 6 | led | ||
| 7 | ocupado1 |