Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Coin Counting Machine with IR Sensors and 16x2 I2C LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Coin Counting Machine with IR Sensors and 16x2 I2C LCD Display

Circuit Documentation

Summary

This circuit is a coin counting machine that uses multiple IR sensors to detect coins and displays the count on a 16x2 I2C LCD. The circuit is controlled by an Arduino UNO microcontroller. The coin values detected are 1 peso, 5 peso, 10 peso, and 20 peso.

Component List

  1. 16x2 I2C LCD

    • Description: A 16x2 character LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  2. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  3. IR Sensor

    • Description: Infrared sensor used to detect the presence of coins.
    • Pins: out, gnd, vcc
  4. Resistor

    • Description: A resistor with a resistance of 1000 Ohms.
    • Pins: pin1, pin2
    • Properties: Resistance: 1000 Ohms

Wiring Details

16x2 I2C LCD

Arduino UNO

IR Sensor 1

IR Sensor 2

IR Sensor 3

IR Sensor 4

Resistor 1

Resistor 2

Resistor 3

Resistor 4

Code Documentation

Arduino UNO Code

/*
 * Coin Counting Machine
 * This code reads inputs from IR sensors to detect coins and displays the
 * count on a 16x2 I2C LCD. The coin values are 1 peso, 5 peso, 10 peso, and
 * 20 peso.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Initialize the LCD, set the LCD address to 0x27 for a 16 chars and 2 line
LiquidCrystal_I2C lcd(0x27, 16, 2);

// IR sensor pins
const int irSensor1 = 13;
const int irSensor2 = 12;
const int irSensor3 = 11;
const int irSensor4 = 10;

// Coin counts
int count1Peso = 0;
int count5Peso = 0;
int count10Peso = 0;
int count20Peso = 0;

void setup() {
  // Initialize the LCD
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Coin Counter");

  // Initialize IR sensor pins
  pinMode(irSensor1, INPUT);
  pinMode(irSensor2, INPUT);
  pinMode(irSensor3, INPUT);
  pinMode(irSensor4, INPUT);
}

void loop() {
  // Check IR sensors
  if (digitalRead(irSensor1) == LOW) {
    count1Peso++;
    displayCount();
    delay(500); // Debounce delay
  }
  if (digitalRead(irSensor2) == LOW) {
    count5Peso++;
    displayCount();
    delay(500); // Debounce delay
  }
  if (digitalRead(irSensor3) == LOW) {
    count10Peso++;
    displayCount();
    delay(500); // Debounce delay
  }
  if (digitalRead(irSensor4) == LOW) {
    count20Peso++;
    displayCount();
    delay(500); // Debounce delay
  }
}

void displayCount() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("1P: ");
  lcd.print(count1Peso);
  lcd.setCursor(8, 0);
  lcd.print("5P: ");
  lcd.print(count5Peso);
  lcd.setCursor(0, 1);
  lcd.print("10P: ");
  lcd.print(count10Peso);
  lcd.setCursor(8, 1);
  lcd.print("20P: ");
  lcd.print(count20Peso);
}

IR Sensor Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This concludes the documentation for the coin counting machine circuit.