Tann Thona: Arduino

Telecommunication and Electronic Engineering

Post

Post Top Ad

Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Thursday, April 4, 2024

Smart Detecting Train Auto Control Gate

April 04, 2024 0

Royal University of Phnom Penh

Faculty of Engineering

Dep. of Telecommunication and Electronic Engineering



Course: Electronic System Design

Project Title:

Smart Detecting Train Auto Control Gate


Group member:

Ly Seyha, Tann Thona, Chhoy Noreath, Nop Da, Ham Sovann, Simpich Dany

Advisor: Chan Tola


1st Generation, Year 4th Semester I

2017-2018

Project Smart Detecting Train Auto Control Gate


Smart Detecting Train Auto Control Gate


I. Abstract

In this article, we aim to build an electronic project is a Smart Detecting Train Auto Control Gate to control traffic of the quadrilateral road of the train and cars road. In this project, we will use 3 main controllers; microcontroller, sensor, and servo motor. we have developed it by invented a new board as Arduino board by using an ATmega328P microcontroller instead of Uno Arduino to control the project process, IR sensor type of TCRT5000 to cooperate with our new board to detect the train coming and then feedback the signal to the microcontroller for control the traffic light, buzzer and servo motor for on/off gate to prevent accident of cars and the train. The invention of the new board is too many steps to do, we will show the board invention of each step in the detail of article below. We have made a new board in order to control the process instead of the Arduino board, so this is a powerful project that we can make a PCB by our own.

II. Introduction

In Cambodia, nowadays there is not so strong in using electronic system to control the system along the railroad, usually we see just the manual system in this case, so we will have an idea to make a system which it works automatically by electronic components in it. This is called Smart Detecting Train Auto Control Gate, it is an Arduino project which we built it with the process commonly as the reality in training process. It is working by automatically in detecting the coming train in a specific distance and then command to traffic light and on-off the gate. It is a powerful project that we have developed by using a main board of a new making PCB with a ATmega328 instead of using the Arduino board in controlling the whole process of our project. In this project, we have used two more important components: servo motors and sensors. we used IR sensor type TCRT5000 to detect train and feedback to a microcontroller while the train is coming for control the traffic light, buzzer and on/off gate to stop cars by servo motors for prevention accident at the quadrilateral road between cars road and railroad. There are 6 pairs of IR sensor along the two part of railroad which there are 3 pairs of sensors to control a direction and 3 more pairs to control another, we have arranged it because we have imagined that we need more safety and smoothly to process on it. Two servo motors are used in controlling in on/off gate when the train coming and across and the traffic light is just used LEDs to output.

We made it up in order to:
  • To learn about electronic components.
  • To show the powerful of electronic components in automatically working.
  • To understand the process in developing project and in reality
  • To compare process in project and reality working.
  • To know the designing of PCB by using software.
  • To know about making a new PCB as Arduino.
  • To show that we can making a controller PBC by our own selves.

III. Electronic Requirement

Base on this whole project, some requirement electronic components is list below:
  • Mini Servo x2
  • ATmega328P x1
  • Crystal 16MHz x1 and Capacitor Ceramic 22pF x2
  • IR sensor (TCRT5000) x6
  • LDR Sensor x1
  • LED (Red x3, Greenx2, Yellow x2 and White x8)
  • Resistor (10Kohm x7, 330ohm x 6 and 100ohm x2)
  • Capacitor Ceramic (100nF x2)
  • Capacitor Electrolyte 10uF x2
  • Adapter DC 9 or 12V (1 - 1.2A)
  • 12vDC Connector x1
  • Switch 12v x1
  • Terminal Block 2pins x1
  • Button x1
  • Regulator (L7805) x1
  • PCB (77mm x 72mm)
  • Jumper wire

1. TCRT5000 IR Sensor


There are two IR LEDs in a TCRT500 that blue LED is transmitter and black LED is a receiver. IR receiver is a potentiometer that is resistor has value depend on IR light.

It works by transmitter LEDs transmit the IR light while the receiver receives the IR light by reflecting signal from object to making change the resistance value. The resistance value of transmitter should be the same of LED’s resistance value and receiver should more than 1Kohm. See Figure 1 below for IR Sensor characteristic and Its working.




Figure 1: IR Sensor characteristic and Its working.


2. Servo Motor

In this project, we use servo motor to control to on-off gate when the train goes through that way.
  • It operates voltage from 4.8 – 6v
  • Stall torque: 1.8 kg.cm (4.8V), 2.2 kg.cm (6 V)
  • Operating speed: 0.1 s/60 degree (4.8 V), 0.08 s/60 degree (6 V).

Figure 2: Servo motor specification.


3. ATmega328P

We used ATmega328P instead of Arduino board process of controlling, it is operating well with 1.8-5.5V of input voltage. It needed a crystal clock with two ceramic capacitors and a 10KOmh resistor and a button for reset to working our microcontroller.
  • Pin 1 is a reset pin to connect with a button.
  • Pins 2&3 are the Rx and Tx pins.
  • Pins 4 to 6 and 11 to 19 are the output digital pins.
  • For pins 7&8 are the power pins of VCC and GND.
  • For pins 9&10 are the connection pins of crystal with 2 capacitors.
  • For pins 23-28 are the output analog pins.

Figure 3: Pins connection diagram for ATmega328P.


IV. Methodology

1. Making Print Circuit Board(PCB)

1.1 PCB Software Design

Base on this project, we have used 2 kind of software programs of Proteus to make new a PCB:


Figure 4: Interface of Proteus ISIS design circuit schematic with v7.10.

Figure 5: Interface of Proteus ARES design layout diagram with v7.10.

  • Proteus ISIS software v7.10: is used to draw the circuit diagram by connecting from any components which we necessary need for our project. It is also corporates to an ARES software program. See Figure 4 below for ISIS design.
  • Proteus ARES software v7.10: used to draw a layout of PCB diagram which connect form ISIS schematic design. See Figure 5 below for ARES design layout diagram.
*Note: in these combining program, some package may not have in this software, so you need to draw it by manually.
Go to this link to download software of the Proteus.v7.10 for the designing circuit schematic and diagram: Download Proteus.v7.10 Software

1.2 PCB Hardware

After we already design the diagram in Proteus software, then we need to follow these below steps:


Figure 6: Making PCB hardware with step by step.


These above figures show the steps of how to make a new PCB:
  • For Fig6.1, show the printing out of the circuit drawing on a slipper paper by the Laserjet printer.
  • Fig6.2, Iron that printed paper on the PCB board with a specific size.
  • Fig6.3, Put the PCB which already ironed into acid and making vibrate it carefully.
  • After we finish these 3 steps above then we need to apply all components to PCB board of each its position and then soldering it one by one. See Fig6.4&6.5.

V. Experiment

1. Program on ATMEGA328P Microcontroller


This is the explains how to migrate from an Arduino board to a standalone the ATmega328P microcontroller on a breadboard for burning the bootloader and uploading program to it.

Unless you choose to use the minimal configuration described at the end of this tutorial, we'll need four main components (besides the Arduino, ATmega328, and breadboard):
  • a 16 MHz crystal,
  • a 10k resistor, and
  • two 18 or 22 picofarad (ceramic) capacitors.

1.1 Burning the Bootloader

We need to burn the bootloader onto a new ATmega328P microcontroller by using an Arduino board as an in-system program (ISP).


Figure 7: Wire connection to burn the bootloader onto an ATmega328P with Uno Arduino.


We’re choosing an Uno Arduino board for this section, so to burn the bootloader, we need to follow these below steps:
  • Firstly, need to upload the ArduinoISP sketch onto an original Arduino board by select the board and serial port from the Tools menu that correspond to our board.
  • Wire up the Arduino board and microcontroller as shown in the diagram of Figure7.
  • Select "Arduino Duemilanove" from the Tools -> Board menu and then select to ATmega328.
  • Select "Arduino as ISP" from Tools -> Programmer
  • Run Tools -> Burn Bootloader
You should only need to burn the bootloader once. After you've done so, you can remove the jumper wires connected to pins 10, 11, 12, and 13 of the Arduino board.

1.2 Uploading Using an Arduino Board

After ATmega328P has the Arduino bootloader on it, then we can upload programs to it by using the USB-to-serial convertor (FTDI chip) on an Arduino board.

  • To upload our code onto it, need to remove the microcontroller from the Uno Arduino board so the FTDI chip can talk to the microcontroller on the breadboard instead.
  • Connect the RX and TX lines from the Arduino board to our ATmega328 on the breadboard as shown in Figure 8.
  • To program the microcontroller, select "Arduino Duemilanove " from the the Tools > Board menu and select ATmega328, then upload as usual.

Figure 8: Wire connection to uploading sketches code to an ATmega328P on a breadboard.


1.3 Algorithm of Project

In this section, we will introduce you to know about our project processing in the diagram, see Figure 9 below to understand well.

To make a process in this project, we need to do the coding. For coding, you can download in link:


Figure 9: Processing of Smart Detecting Train Auto Control Gate.



Figure 10: Flow Char


VI. Result

After we spent 10 weeks to develop it, finally we have completed it with 90% of fully project.
According to this project, there are two main parts, the smart detecting train system and auto night light system on this project. Let see the result of our full project’s demo is in the link below.


Figure 11: Result of Smart Detecting Train Auto Control Gate.



VI. Conclusion

In sum, we have developed an electronic project which work automatically to traffic light and gate control by detecting the coming train at quadrilateral road. We have made a new PCB board which include a new chip ATmega328P and all-important components on it to cover to a whole project’s process that can be replacement to an Uno Arduino board. Finally, it is working 90% of fully project and we need to update it with any remaining part and something lost in order to finish our project completely.

After we have finished this project, we knew many things about this project:
  • Knew some electronic components characteristic and its specification.
  • Understood the process in developing project and in reality.
  • Know the comparing of process in project and reality working.
  • Understood well about the designing of PCB by using Proteus software.
  • Knew about how making a new PCB and boot-loading the ATmega328P as Arduino.


Reference


[1]. https://www.arduino.cc/en/Tutorial/ArduinoToBreadboard

[2]. https://nomada-e.com/store/sensores/9-sensor-optico-reflectivo-tcrt5000.html

[3]. http://full-parts.com/mg90s-metal-gear-servo-for-arduino-micro-tower-pro-180-degrees.html

[4]. https://voidyourwarranty.wordpress.com/2014/08/17/using-arduino-as-an-isp-to-program-a-standalone-atmega-328p-including-fuses/


Photos

Date: 20 December 2017
Location: Royal University of Phnom Penh, Cambodia














Read More

Monday, April 1, 2024

Arduino Project Set Real Time Control Light 7 Segment

April 01, 2024 1

Set Real Time Control Light Using 7 Segment


1. Abstract

Traditionally electrical light control by Time that regulate the electricity to these device. Time control light works by making everything in your house that turn on or turn of automatic controlled using technology control and do job that we would normally do manually. Light automatic take care of a lot of different activities in the house.

2. Introduction

In this project we want to do how to turn ON/OFF LED by press button as a switch to control Light of LED. We have three button for set time to turn on and turn of LED light. we used Real Time Clock (DS3231 module) to keep tract of the time even if the microcontroller is disconnect the main power because RTC run on its own batter like our clock. Using two of 7 segments cathode to display time by get real time from DS3231 module.
 

3. Objective

The main objective of this project is: that we are control light at our home using simple circuit.
  • Display Real Time on 7 segment
  • Set Time Automatic Turn ON LED Light
  • Set Time Automatic Turn OFF LED Light

4. Electronic Requirement

Electronic requirement use in this project:
  • Arduino Meg 2560
  • RTC DS3231 Module
  • 7 Segment Two Digit Cathode Type (x2)
  • Button (x3)
  • Resistance 330 Ohm (x6)
  • LED Red(x2) Wite(x1)
  • Breadboard (x1)
  • USB Connected from Arduino to Computer
  • Jumper Wire

5. Methodology

To create this project we use Arduino Meg 2560 as a main controller and 7segment show time clock, button set time such as minute and hour and LED turn on/off light. RTC DS3231 module to keep the time alive, and Arduino as a software for transfer the data from device to laptop or computer.
  • Controller
The Arduino Mega is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins, 16 analog inputs, 4 UARTs (hardware serial ports), a 16MHz crystal oscillator, a USB connection, a power jack and a reset button.

Figure 1: Arduino MEGA 2560)

  • RTC DS3231 Module
We need to use Real-time Clock (RTC DS3231) to keep tract of the time even if we program the microcontroller or disconnect the main power because RTC run on it own batter like our clock.
The DS3231 is low-cost, highly accurate real-time which can maintain hours, minute, and seconds. This module work on both 3.3v and 5v that make it suitable for using with microcontroller (Arduino).

Figure 2: DS3231 Real-time Clock Module

  • 7 Segment Cathode Two Digit
7 Segment (cathode type) has 10 pins. 2 pins are GND (one for one’s digit) and others 8 pins are get power source for display number.


Figure 3: 7Segment Cathode Two Digit

  • Button
Button is similar switch too. If we press button it like switch open, but if we release it like switch close. We use button in this project to set time for torn on the light and turn off the light.

Figure 4: Button

  • LED
We use LED to show light depend on time that we set turn on or turn off.


Figure 5: LED

5.2 Circuit Diagram

Connect Arduino pins to RTC and 7 Segment like diagram bellowed:
  • RTC DS3231 Module
Table Connection RTC to Arduno

Figure 6: The circuit of connection from Arduino MEGA to RTC

  • 7 Segment Cathode Two Digit
Table Connection 7 Segment to Arduino


Figure 7: The circuit of connection from Arduino MEGA to 7 Segment

5.3 Algorithim of Project

For this project we have 3 buttons to set time turn on and turn off LED light. The first button is use for save time and change digit edit time value. Second button use for go to set time turn on LED light and decrease time value. The last button use for go to set time turn off LED light and increase time value. DS312 module is keeping track of the time and 7 Segment display clock number.

Figure 8: Full Diagram of Project

Flow Chart Process

5.4 Coding

First open arduino software plus Arduino Mega USB Cable to computer and the select port:



After connect pin RTC DS3231 module like above then upload code set real time to RTC like below:

//#include <SPI.h>
#include <DS3231.h> //Library for RTC module (Download from Link in article)
DS3231 rtc(SDA, SCL);
void setup()
{
Serial.begin(9600);
//SPI.begin(); /* Enable the SPI interface */
rtc.begin(); // Initialize the rtc object
rtc.setTime(13, 52, 00); // Set the time to 12:00:00 (24hr format)
rtc.setDate(13, 3, 2018); // Set the time to 12:00:00 (24hr format)
}
Void loop()
{
}

*Note: You have to add library DS3231 in to this software.

Then download code and upload to your arduino: Download Code



6. Result

After upload code to Arduino already we get result like below:

  • 7 Segment display real time clock by get time from DS3231.
  • Button 2 (Middle): press a second 7 Segment will go to set time turn on LED mode. In mode set time if click less than a second on Button it will increase number on 7 Segment.
  • Button 3 (Right): press a second 7 Segment will go to set time turn off LED mode. In mode set time if click less than a second on Button it will decrease number on 7 Segment.
  • Button 1 (Left): press a second in set time mode it will save time value. But if we click less than a second it will change digit for edit number of time.
  • LED will turn on/off when time we set the same real time.





Royal University of Phnom Penh
Faculty of Engineering
Dep. Telecommunication and Electronic Engineering

Group Member:
1. Tann Thona
2. Sim Pichdany
3. Ven Seyha
Instructor: Prof. Kuong Samnang
Date: 16 March 2018
Read More

Monday, January 11, 2021

មេរៀនទី២៥៖ Keypad 4x6

January 11, 2021 0

Keypad 4x6

 

1. Objective

The objective is talk about, how to use keypad 4x6 on arduino.

2. Requirement

  • Arduino Uno x1
  • Keypad 4x6 
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • Electronic Wire (No need in simulation) 

 

3. Build Circuit

Build circuit like Figure 1.
 

Figure 1. Arduino Connection


 

4. Coding

 Make sure you are ready add keypad library on arduino IDE before write keypad matrix code. if you are not yet add keypad library, so follow instruction install library show below:

 

Step 1: Your computer have to connect internet.

Step 2: On arduino IDE, Sketch → Include Library → Manage Libraries

Step 3: After show form like figure 2, so search "keypad" and install it.

 

Figure 2. Keypad Installation

After install keypad library now you can program on arduino.


// Coding by Tann Thona (10/12/2020)
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 6; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'C','7','8','9','X','/'},
{'A','4','5','6','-','R'},
{'%','1','2','3','+','D'},
{'R','0','.','=','+','P'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {11, 10, 9, 8, 7, 6}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
Serial.begin(9600);
}

void loop(){
char customKey = customKeypad.getKey();

if (customKey){
Serial.println(customKey);
}
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, when we click on keypad then on virtue terminal or serial monitor will display character as symbol in matrix code.

Watch Video Explain in Khmer




YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

Sunday, January 10, 2021

មេរៀនទី២៤៖ Keypad 4x4

January 10, 2021 0

Keypad 4x4

 

1. Objective

The objective is talk about, how to use keypad 4x4 on arduino.

2. Requirement

  • Arduino Uno x1
  • Keypad 4x4 
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • Electronic Wire (No need in simulation) 

 

3. Build Circuit

Build circuit like Figure 1.
 

Figure 1. Arduino Connection

 

 

4. Coding

 Make sure you are ready add keypad library on arduino IDE before write keypad matrix code. if you are not yet add keypad library so follow instruction install library show below:

 

Step 1: Your computer have to connect internet.

Step 2: On arduino IDE, Sketch → Include Library → Manage Libraries

Step 3: After show form like figure 2, so search "keypad" and install it.

 

Figure 2. Keypad Installation

After install keypad library now you can program on arduino.


// Coding by Tann Thona (08/12/2020)
#include <Keypad.h>

const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'7','8','9','/'},
{'4','5','6','x'},
{'1','2','3','-'},
{'C','0','=','+'}
};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {10, 9, 8, 7}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
Serial.begin(9600);
}

void loop(){
char customKey = customKeypad.getKey();

if (customKey){
Serial.println(customKey);
}
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, when we click on keypad then on virtue terminal or serial monitor will display character as symbol on keypad .

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

Thursday, January 7, 2021

មេរៀនទី២៣៖ Display Lux Brightness Measurements on LCD 16x2 LCD Screens Using LDR Sensors

January 07, 2021 0

Display Light Sensor on LCD 16x2 Screen

 

1. Objective

The objective is talk about, Use LDR sensor to measure light in lux and display on LCD 16x2 screen.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • LDR x1 (Name in Proteus: TORCH LDR)
  • Resistor 10 KOhm x1
  • Potentiometer 4.7KOhm or 10KOhm x1 (Name in Proteus: POT-HG)
  • Electronic Wire (No need in simulation) 

 

3. Build Circuit

Build circuit like Figure 1.


Figure 1. Arduino Connection

 

4. Coding

// Coding by Tann Thona (06/12/2020)
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
float LDR = 0;
float Vout = 0;
float R1 = 1000;
float Lux = 0;
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setCursor(6,0);
lcd.print("Lux:");
pinMode(A0,INPUT);
}

void loop() {
// Turn off the display:
LDR = analogRead(A0);
Vout = (5*LDR)/1023;

Lux = ((25000/Vout) - 500) / R1;

lcd.setCursor(6, 1);
lcd.print(Lux);
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, The LCD 16x2 screen will display on top column "Lux" and under column display number of light measurement in lux depend on environment's bright.

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

Tuesday, January 5, 2021

មេរៀនទី២២៖ LCD 16x2 Display Automatic Scroll Text

January 05, 2021 0

LCD 16x2 Display Automatic Scroll

 

1. Objective

The objective is talk about, display LCD 16x2 text with automatic scroll.

2. Requirement

  • Arduino Uno x1
  • LCD 16x2 x1 (Name in Proteus: LM016L)
  • Potentiometer 4.7Kohm or 10Kohm x1 (Name in Proteus: POT-HG)
  • USB Cable x1(No need in simulation)
  • Breadboard x1 (No need in simulation)
  • Electronic Wire (No need in simulation)

 

3. Build Circuit

Build circuit like Figure 1.

Figure 1. Arduino Connection


 

4. Coding

// Coding by Tann Thona (04/12/2020)
// include the library code:
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

char Array[16] = {'H', 'E', 'L', 'L', 'O', ' ', 'W', 'O', 'R', 'l', 'D', ' ', '2', '0', ' ', ' '};

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setCursor(4,0);
lcd.print("Welcome");

}

void loop() {
// Turn off the display:
lcd.setCursor(0,1);
for(int i = 0; i<=15; i++)
{
lcd.print(Array[i]);
}
delay(70);

lcd.setCursor(0, 1);
char swap = Array[0];
for(int j=0; j<15; j++)
{
Array[j] = Array[j+1];
}
Array[15] = swap;
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, on column 1 (top) is display "Welcome" and column 2 (under) is display "HELLO WORLD  20  " with automatic scroll.

Watch Video Explain in Khmer




YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

Sunday, January 3, 2021

មេរៀនទី២១៖ LCD 16x2 Text Display

January 03, 2021 0

LCD 16x2 Text Display

 

1. Objective

The objective is talk about, how to LCD 16x2 display text on screen.

2. Requirement

  • Arduino Uno x1
  • LCD 16x2 x1 (Name in Proteus: LM016L)
  • Potentiometer 4.7Kohm or 10Kohm x1 (Name in Proteus: POT-HG)
  • USB Cable x1(No need in simulation)
  • Breadboard x1 (No need in simulation)
  • Electronic Wire (No need in simulation) 

 

3. Build Circuit

Build circuit like Figure 1.
 
 
Figure 1. Arduino Connection


4. Coding

// Coding by Tann Thona (03/12/2020)
#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(1,0);
lcd.print("Welcome 2021");

lcd.setCursor(2,1);
lcd.print("TANN THONA");
}

void loop() {
// Turn off the display:

}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, LCD will display text on column 1 "Welcome 2021" and column 2 "TANN THONA".

Watch Video Explain in Khmer


YouTube: ICT4D-KH
Copyright By Tann Thona


Read More

Wednesday, December 23, 2020

មេរៀនទី២០៖ 7 Segment Two Digits Cathode Type

December 23, 2020 0

7 Segment Two Digits Cathode Type

 

1. Objective

The objective is talk about, Use 7 segment 2 digits cathode type display count up number.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • 7 Segment 2 digits x1 (Cathode Type)
  • Resistor 220Ohm x2
  • Electronic Wire (No need in simulation) 

 

3. Build Circuit

Build circuit like Figure 1. 
 
Segment Pin A to Arduino pin 13 
Segment Pin B to Arduino pin 12
Segment Pin C to Arduino pin 11 
Segment Pin D to Arduino pin 10
Segment Pin E to Arduino pin 9
Segment Pin F to Arduino pin 8
Segment Pin G to Arduino pin 7 
Segment Pin D1 to Arduino pin 6 
Segment Pin D2 to Arduino pin 5
 
*Note you must find pin A, B, C, D, E, F, G, D1 and D2 in real 7 segment because the pin are not order as simulation. 
 
Figure 1. Arduino Connection

 

4. Coding

// by Tann Thona
// 7 Segment 2 digits cathode

int pinA = 13;
int pinB = 12;
int pinC = 11;
int pinD = 10;
int pinE = 9;
int pinF = 8;
int pinG = 7;
int D2 = 6;
int D1 = 5;
int j = 0;
int i = 0;
int k = 0;

int Arduino_Pins[7] = {pinA, pinB, pinC, pinD, pinE, pinF, pinG}; // an array of pin numbers to which LEDs
int Segment_Pins[10][7] = {{1, 1, 1, 1, 1, 1, 0}, // 0
{0, 1, 1, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1}, // 2
{1, 1, 1, 1, 0, 0, 1}, // 3
{0, 1, 1, 0, 0, 1, 1}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 0, 1, 1, 1, 1, 1}, // 6
{1, 1, 1, 0, 0, 0, 0}, // 7
{1, 1, 1, 1, 1, 1, 1}, // 8
{1, 1, 1, 1, 0, 1, 1}, // 9
};

void setup() {
// put your setup code here, to run once:
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
}

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

for (int t = 0; t < 20; t++) // int t = 0; t < 500; t++
{
digitalWrite(D1, 0);
digitalWrite(D2, 1);
for (j = 0; j < 7; j++)
{
digitalWrite(Arduino_Pins[j], Segment_Pins[i][j]);
}
delay(100); // delay(1);

digitalWrite(D1, 1);
digitalWrite(D2, 0);
for (j = 0; j < 7; j++)
{
digitalWrite(Arduino_Pins[j], Segment_Pins[k][j]);
}
delay(100); // delay(1);


i++;
if (i == 9)
{
i = 0;
k++;
if (k == 9)
{
k = 0;
}

}
}
}

Click here to download code and simulation file

 

4. Result

According to code above,7 segment is display with count up number from 0 to 99 in loop.

Watch Video Explain in Khmer




YouTube: ICT4D-KH
Copyright By Tann Thona


Read More

Post Top Ad