Automatic items counter is a fast and precise tool for humans to get the sum of items. The purpose of this project is to provide education to the wider community on how to make a simple automatic item counter. This project has been implemented and took approximately 2 weeks. This system is made to be used as a complement to the conveyor. In addition, this system has also provided display and reset features for the needs of its users. The way this system works is that if the items transported by the conveyor are right in front of the laser beam, the light intensity received by the LDR sensor is low, so it is considered that there are items and starts counting. The calculation results will be displayed on the LCD screen. This project will be useful for business people, because it can increase efficiency in production. The results show that this system can function properly.
Part | Description |
---|---|
Development Board | STM8S103F3P6 |
Code Editor | Arduino IDE |
Programmer Tools | ST-Link/V2 |
Serial Communication Tools | FTDI USB |
Driver | • ST-Link USB Driver • CDM FTDI USB Driver |
Communications Protocol | Inter Integrated Circuit (I2C) |
Programming Language | C/C++ |
Arduino Library | LiquidCrystal_I2C (default) |
Sensor | • LDR Sensor Module (x1) • KY-008: Laser Transmitter Module 5V (x1) |
Display | LCD I2C (x1) |
Other Components | • Micro USB cable - USB type A (x1) • Mini USB cable - USB type A (x1) • Jumper cable (1 set) • Adaptor DC 5V (x1) • Breadboard (x1) • Push button 12 x 12 mm |
-
Arduino IDE
https://bit.ly/ArduinoIDE_Installer
-
ST-Link USB Driver
https://bit.ly/STLink_USB_Driver
-
CDM FTDI USB Driver
https://bit.ly/CDM_FTDI_USB_Driver
Block Diagram | Pictorial Diagram |
---|---|
Wiring |
---|
#include <Wire.h>
void setup() {
Wire.begin();
Serial.begin(9600);
while (!Serial); // Wait for serial monitor
Serial.println("\nI2C Scanner");
}
void loop() {
int nDevices = 0;
Serial.println("Scanning...");
for (byte address = 1; address < 127; ++address) {
// The i2c_scanner uses the return value of the Wire.endTransmission to see if a device did acknowledge to the address.
Wire.beginTransmission(address);
byte error = Wire.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.print(address, HEX);
Serial.println(" !");
++nDevices;
} else if (error == 4) {
Serial.print("Unknown error at address 0x");
if (address < 16) {
Serial.print("0");
}
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No I2C devices found\n");
} else {
Serial.println("done\n");
}
delay(5000); // Wait 5 seconds for next scan
}
-
Open the
Arduino IDE
first, then open this project by clickingFile
->Open
:auto_counter.ino
-
Fill in the
Additional Board Manager URLs
in Arduino IDEClick
File
->Preferences
-> enter theBoards Manager Url
by copying the following link :https://github.com/tenbaht/sduino/raw/master/package_sduino_stm8_index.json
-
Board Setup
in Arduino IDEHow to setup the
STM8S103F3P6
board• Click
Tools
->Board
->Boards Manager
-> InstallSduino STM8 plain C core (non-C++)
.• Then click
Tools
->Board
->STM8S Boards
->STM8S103F3 Breakout Board
.
-
Change Programmer
in Arduino IDEClick
Tools
->Programmer
->ST-Link/V2
-
Before uploading the program please click:
Verify
. -
If there is no error in the program code, the next step is to use the
STM8
programming tool according to the procedure. Then click:Upload
. -
If there is still a problem when uploading the program, then try checking the
driver
/port
/programmer tool
/others
section.
The single wire interface module or
SWIM
is basically used to communicate with theSTM8
board.You can see the wiring between the
ST-Link/V2
and theSTM8
board in detail in the picture above.Based on personal experience, the
STM8
can only be programmed withST-Link
.
Serial communication on this
STM8
board is very possible, especially forSerial Monitor
andSerial Plotter
purposes. Tools that can be used for serial communication include:CP2102 USB
,CH340 USB
,FTDI USB
, or withPL2303 USB
.You can see the wiring between the
FTDI USB
and theSTM8
board in detail in the picture above.Based on experience, I admit that using
FTDI USB
orCP2102 USB
is much better thanPL2303 USB
orCH340 USB
because they are known to be more stable in performance.
The write protection on the STM8
can be removed through several steps, among others :
-
Open
CMD (Command Prompt)
. -
Enter into the directory :
C:\Users\[Computer Name]\AppData\Local\Arduino15\packages\sduino\tools\STM8Tools\2019.02.05\win
-
Input the command:
stm8flash -cstlinkv2 -pstm8s103?3 -u
-
Press
Enter
, then you can see the result as the picture below.
-
Download and extract this repository.
-
Make sure you have the necessary electronic components.
-
Make sure your components are designed according to the diagram.
-
Configure your device according to the settings above.
-
Please enjoy [Done].
If this work is useful to you, then support this work as a form of appreciation to the author by clicking the ⭐Star
button at the top of the repository.
This application is my own work and is not the result of plagiarism from other people's research or work, except those related to third party services which include: libraries, frameworks, and so on.
MIT License - Copyright © 2024 - Devan C. M. Wijaya, S.Kom
Permission is hereby granted without charge to any person obtaining a copy of this software and the software-related documentation files to deal in them without restriction, including without limitation the right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons receiving the Software to be furnished therewith on the following terms:
The above copyright notice and this permission notice must accompany all copies or substantial portions of the Software.
IN ANY EVENT, THE AUTHOR OR COPYRIGHT HOLDER HEREIN RETAINS FULL OWNERSHIP RIGHTS. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, THEREFORE IF ANY DAMAGE, LOSS, OR OTHERWISE ARISES FROM THE USE OR OTHER DEALINGS IN THE SOFTWARE, THE AUTHOR OR COPYRIGHT HOLDER SHALL NOT BE LIABLE, AS THE USE OF THE SOFTWARE IS NOT COMPELLED AT ALL, SO THE RISK IS YOUR OWN.