Tann Thona: Arduino Lesson

Telecommunication and Electronic Engineering

Post

Post Top Ad

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

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

មេរៀនទី១៩៖​ 7 Segment one Digit Cathode Type Using Matrix Code

December 23, 2020 0

7 Segment one Digit Cathode Type

 

1. Objective

The objective is talk about, Use matrix code (Array) to display 7 segment one digit cathode type.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • 7 Segment one digit x1 (Anode Type)
  • Resistor 220Ohm x1
  • 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
 
*Note you must find pin A to G in real 7 segment because the pin are not order as simulation. 
 

Figure 1. Arduino Connection

4. Coding

// by Tann Thona
// 7 Segment Cathode Type

int pinA = 13;
int pinB = 12;
int pinC = 11;
int pinD = 10;
int pinE = 9;
int pinF = 8;
int pinG = 7;
int j = 0;
int i = 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);
}

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

for (j = 0; j<7; j++)
{
digitalWrite(Arduino_Pins[j], Segment_Pins[i][j]);
}
delay(100);

i++;
if(i>10)
{
i = 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 9 in loop.

Watch Video Explain in Khmer




YouTube: ICT4D-KH
Copyright By Tann Thona


Read More

Tuesday, December 22, 2020

មេរៀនទី១៨៖ 7 Segment one Digit Anode Type (Simple Code)

December 22, 2020 0

7 Segment one Digit Anode Type

 

1. Objective

The objective is talk about, Use digital output to display 7 segment one digit anode type.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • 7 Segment one digit x1 (Anode Type)
  • Resistor 220Ohm x1
  • 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
 
*Note you must find pin A to G in real 7 segment because the pin are not order as simulation.


Figure 1. Arduino Connection


4. Coding

// by Tann Thona
// 7 Segment Anode Type

int pinA = 13;
int pinB = 12;
int pinC = 11;
int pinD = 10;
int pinE = 9;
int pinF = 8;
int pinG = 7;

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);

}

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

// Number 0
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 1);
delay(100);

// Number 1
digitalWrite(pinA, 1);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 2
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 1);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 1);
digitalWrite(pinG, 0);
delay(100);

// Number 3
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 0);
delay(100);

// Number 4
digitalWrite(pinA, 1);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 5
digitalWrite(pinA, 0);
digitalWrite(pinB, 1);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 1);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 6
digitalWrite(pinA, 0);
digitalWrite(pinB, 1);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 7
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 8
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 9
digitalWrite(pinA, 0);
digitalWrite(pinB, 0);
digitalWrite(pinC, 0);
digitalWrite(pinD, 0);
digitalWrite(pinE, 1);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);
}

 Click Here to Download Code and Proteus Simulation

 

4. Result

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

Watch Video Explain in Khmer




YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

Monday, December 21, 2020

មេរៀនទី១៧៖​ 7 Segment one Digit Cathod Type (Simple Code)

December 21, 2020 0

7 Segment one Digit Cathode Type

 

1. Objective

The objective is talk about, Use digital output to display 7 segment one digit cathode type.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • 7 Segment one digit x1 (Cathode Type)
  • Resistor 220Ohm x1
  • 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
 
*Note you must find pin A to G in real 7 segment because the pin are not order as simulation.



Figure 1. Arduino Connection

4. Coding

// by Tann Thona
// 7 Segment Cathod Type

int pinA = 13;
int pinB = 12;
int pinC = 11;
int pinD = 10;
int pinE = 9;
int pinF = 8;
int pinG = 7;

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);

}

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

// Number 0
digitalWrite(pinA, 1);
digitalWrite(pinB, 1);
digitalWrite(pinC, 1);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 0);
delay(100);

// Number 1
digitalWrite(pinA, 0);
digitalWrite(pinB, 1);
digitalWrite(pinC, 1);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 2
digitalWrite(pinA, 1);
digitalWrite(pinB, 1);
digitalWrite(pinC, 0);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 0);
digitalWrite(pinG, 1);
delay(100);

// Number 3
digitalWrite(pinA, 1);
digitalWrite(pinB, 1);
digitalWrite(pinC, 1);
digitalWrite(pinD, 1);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 1);
delay(100);

// Number 4
digitalWrite(pinA, 0);
digitalWrite(pinB, 1);
digitalWrite(pinC, 1);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 5
digitalWrite(pinA, 1);
digitalWrite(pinB, 0);
digitalWrite(pinC, 1);
digitalWrite(pinD, 1);
digitalWrite(pinE, 0);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 6
digitalWrite(pinA, 1);
digitalWrite(pinB, 0);
digitalWrite(pinC, 1);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 7
digitalWrite(pinA, 1);
digitalWrite(pinB, 1);
digitalWrite(pinC, 1);
digitalWrite(pinD, 0);
digitalWrite(pinE, 0);
digitalWrite(pinF, 0);
digitalWrite(pinG, 0);
delay(100);

// Number 8
digitalWrite(pinA, 1);
digitalWrite(pinB, 1);
digitalWrite(pinC, 1);
digitalWrite(pinD, 1);
digitalWrite(pinE, 1);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);

// Number 9
digitalWrite(pinA, 1);
digitalWrite(pinB, 1);
digitalWrite(pinC, 1);
digitalWrite(pinD, 1);
digitalWrite(pinE, 0);
digitalWrite(pinF, 1);
digitalWrite(pinG, 1);
delay(100);
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

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

Watch Video Explain in Khmer




YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

Sunday, December 20, 2020

មេរៀនទី១៦៖​ Use LDR Sensor Control Three LEDs (RGB)

December 20, 2020 0

LDR Sensor Control Three LEDs

 

1. Objective

The objective is talk about, Use LDR sensor to control digital pin.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation) 
  • LDR Sensor x1
  • LED x3
  • Resistor (220Ohm or 330Ohm) x3 *Note use to protect LED
  • Resistor 10K x1
  • Electronic Wire (No need in simulation) 
  • Virtue Terminal (For Proteus simulation) 

 

3. Build Circuit

Build circuit like Figure 1.

Figure 1. Arduino Connection


4. Coding

// Tann Thona
int x = 0;
void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
x = analogRead(A0);
if (x >= 0 && x <= 350)
{
digitalWrite(13, 1);
digitalWrite(12, 0);
digitalWrite(11, 0);
}
else if (x > 350 && x <= 700)
{
digitalWrite(13, 0);
digitalWrite(12, 1);
digitalWrite(11, 0);
}
else
{
digitalWrite(13, 0);
digitalWrite(12, 0);
digitalWrite(11, 1);
}
Serial.println(x);
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, these three LEDs (RGB) switching bright depend on light shine on LDR sensor.

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona


Read More

Thursday, December 17, 2020

មេរៀនទី១៥៖​ Use LDR Sensor Control LED

December 17, 2020 0

LDR Sensor

 

1. Objective

The objective is talk about, how to use LDR sensor to control LED.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • LED x1
  • Resistor (220 or 330 Ohm) x1
  • Resistor (10K Ohm) x1
  • Electronic Wire (No need in simulation) \
  • LDR Sensor x1

 

3. Build Circuit

Build circuit like Figure 1.


Figure 1. Arduino Connection

 

4. Coding

// by Tann Thona
int ldr = 0;
void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
ldr = analogRead(A0);
if(ldr < 512)
{
digitalWrite(13, 1);
}
else
{
digitalWrite(13, 0);
}
Serial.println(ldr);
delay(10);
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, if LDR sensor at dark place so LED is on but if LDR sensor at brightness place so LED is off.

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona


Read More

មេរៀនទី១៤៖ Analog Read Control LED Using Potentiometer

December 17, 2020 0

Analog Read

 

1. Objective

The objective is talk about, how to use analog pin read signal for potentiometer to control digital pin arduino.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation) 
  •  Potentiometer x1 (Name in Proteus is POT-HG)
  • LED x3
  • Resistor (220Ohm or 330Ohm) x3
  • Electronic Wire (No need in simulation)
  • Virtual Terminal (for monitor in Proteus)

 

3. Build Circuit

Build circuit like Figure 1.



Figure 1. Arduino Connection

 

4. Coding

// By Tann Thona
// 0V = 0;
// 5V = 1023
// x = (3*1023)/5 = 613.8

int val = 0;
void setup() {
// put your setup code here, to run once:
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
Serial.begin(9600);

}

void loop() {
// put your main code here, to run repeatedly:
val = analogRead(A0);
if(val <= 200)
{
digitalWrite(13, 1);
digitalWrite(12, 0);
digitalWrite(11, 0);
}
else if(val <= 512)
{
digitalWrite(13, 0);
digitalWrite(12, 1);
digitalWrite(11, 0);
}
else if(val <= 1023)
{
digitalWrite(13, 0);
digitalWrite(12, 0);
digitalWrite(11, 1);
}
Serial.println(val);
delay(10);
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, this two LEDs was switching bright depend on potentiometer vary resistance.

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

Tuesday, December 15, 2020

មេរៀនទី១៣៖ Digital Read (INPUT_PULLUP)

December 15, 2020 0

INPUT_PULLUP

 

1. Objective

The objective is talk about, how to use digital read by using INPUT_PULLUP method in arduino to blink LED.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • LED x2
  • Resistor (220Ohm or 330Ohm) x2
  • Electronic Wire (No need in simulation) 
  • Button x1

 

3. Build Circuit

Build circuit like Figure 1.

Figure 1: Arduino Connection

 

4. Coding

// Coding by Tann Thona (22/09/2019)
void setup() {
// put your setup code here, to run once:
pinMode(12, OUTPUT);
pinMode(13, OUTPUT);
pinMode(2, INPUT_PULLUP);

}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(2) == 0)
{
for(int i = 0; i<20; i++)
{
digitalWrite(12, 1);
digitalWrite(13, 0);
delay(30);
digitalWrite(12, 0);
digitalWrite(13, 1);
delay(30);
}
}
else if (digitalRead(2) == 1)
{
digitalWrite(12, 1);
digitalWrite(13, 1);
}
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, if we press button switching blink 20 times and unpressed LEDs is bright .

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

មេរៀនទី១២៖ Digital Read

December 15, 2020 0

Digital Read

 

1. Objective

The objective is talk about, how to use digital read to control LED.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • LED x2
  • Resistor (220Ohm or 330Ohm) x2
  • Electronic Wire (No need in simulation) 
  • Button x1

 

3. Build Circuit

Build circuit like Figure 1.


Figure 1: Arduino Connection

 

4. Coding

// Coding by Tann Thona (22/09/2019)
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(2, INPUT);

}

void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(2) == 1)
{
digitalWrite(13, 1); // HIGH is the same value 1
digitalWrite(12, 0); // LOW is the same value 0
}
else
{
digitalWrite(13, 0); // LOW is the same value 0
digitalWrite(12, 1); // HIGH is the same value 1
}

}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, if we press button one LED is bright and one dark. When we release button this two LED was switching bright and dark.


Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona



Read More

Friday, December 11, 2020

មេរៀនទី១១៖ Blink LED

December 11, 2020 0

Blink LED

 

1. Objective

The objective is talk about, how to use digitalWrite in arduino to blink LED.

2. Requirement

  • Arduino Uno x1
  • USB Cable x1 (No need in simulation)
  • Breadboard x1 (No need in simulation)
  • LED x2
  • Resistor (220Ohm or 330Ohm) x2
  • Electronic Wire (No need in simulation) 

 

3. Build Circuit

Build circuit like Figure 1.


Figure 1: Arduino Connection

 

4. Coding

// Coding by Tann Thona (21/09/2019)
int LED = 13;
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT);
pinMode(12, OUTPUT);


}

void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED,HIGH); // OUTPUT Voltage 5V
digitalWrite(12,0);
delay(500);
digitalWrite(LED, LOW);
digitalWrite(12,1);
delay(500);
}

Click Here to Download Code and Proteus Simulation File 

 

4. Result

According to code above, this two LEDs was switching blink in 0.5 second.

Watch Video Explain in Khmer



YouTube: ICT4D-KH
Copyright By Tann Thona

Read More

មេរៀនទី១០៖ ពន្យល់របៀបប្រើ Breadboard សម្រាប់ត Arduino ជាមួយគ្រឿងអេឡិចត្រូនិច

December 11, 2020 0

Explain Breadboard

 

Watching Video Explain in Khmer



View Power Point Slide

 

    Download:  PowerPoint

 

 

Keyword: Arduino Uno, ATmega328P, Arduino Khmer

Read More

Thursday, December 10, 2020

មេរៀនទី៩៖ របៀបផផ្ទុកកូដចូលក្នុង Arduino និងបំលែងកូដតេស្តលើកម្មវិធី Proteus

December 10, 2020 0

Upload Code to Arduino and Binary Code Simulation on Proteus

 

Watching Video Explain in Khmer



Keyword: Upload Code to Arduino, Binary Code Simulation in Proteus, Proteus Simulation

Read More

មេរៀនទី៨៖ រៀនកូដសម្រាប់បញ្ជា Arduino

December 10, 2020 0

Programing Language in Arduino

 

Watching Video Explain in Khmer


View Power Point Slide

 

    Download:  PowerPoint

 

 

Keyword: Arduino Uno, ATmega328P, Arduino Khmer

Read More

មេរៀនទី៧៖ រៀនកូដសម្រាប់បញ្ជា Arduino

December 10, 2020 0

Programing Language in Arduino

 

Watching Video Explain in Khmer


View Power Point Slide

 

    Download:  PowerPoint

 

 

Keyword: Arduino Uno, ATmega328P, Arduino Khmer

Read More

មេរៀនទី៦៖ រៀនកូដសម្រាប់បញ្ជា Arduino

December 10, 2020 0

Programing Language in Arduino

 

Watching Video Explain in Khmer


View Power Point Slide

 

    Download:  PowerPoint

 

 

Keyword: Arduino Uno, ATmega328P, Arduino Khmer

Read More

Post Top Ad