Call Us Now
0242159130 | 0546096840
Up to 2% reward

For new all Customers

Delevery schedule

We deliver  the same day through VIP bus parcel Service in Ghana

Discount on order gift

Save ¢10.00 when you spend ¢600+! 

Blogs

Latest Blog

19 August, 2019
0 Comment Leave Comments

In this tutorial,we will learn how to measure the distance by the ultrasonic distance sensor. 

Hardware required
1 * Arduino UNO
1 * USB Cable
1 * LCD1602

1*Ultrasonic Distance Sensor 

1 * LCD1602

1 * 10kΩ Potentiometer 

Several jumper wires 

Principle of operation

This recipe uses the popular Parallax PING ultrasonic distance sensor to measure the distance to an object ranging from 2cm to around 3m.

Ultrasonic sensors provide a measurement of the time it takes for sound to bounce off an object and return to the sensor. The “ping” sound pulse is generated when the pingPin level goes HIGH for two micro-seconds. The sensorwillthengenerateapulsethatterminateswhenthesoundreturns.The width of the pulse is proportional to the distance the sound traveled and the sketch then uses the p uls e I n ( ) function to measure that duration.The speed of sound is 340meters per second,which is 29 microseconds per

centimeter.The formula for the distance of the round trip is:

RoundTrip = microseconds / 29.

So, the formula for the one-way distance in centimeters is:

microseconds / 29 / 2

Experiment code

//File name:   Experiment 19

/********************************

Description: When you move the ultrasonic distance sensor,

             you will find LCD1602 display distance.

*******************************/

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/19

#include <LiquidCrystal.h>

const int pingPin = 5;  // pin connected to Echo Pin in the ultrasonic distance sensor

const int trigPin  = 7; // pin connected to trig Pin in the ultrasonic distance sensor


LiquidCrystal lcd(4, 6, 10, 11, 12, 13);   

void setup() 

{

   pinMode(pingPin, INPUT); //Set the connection pin output mode Echo pin

   pinMode(trigPin, OUTPUT);//Set the connection pin output mode trog pin

   lcd.begin(16, 2);        //set up the LCD's number of columns and rows: 

   lcd.clear();             //Clears the LCD screen and positions the cursor in the upper-left corner 

   delay(1000);             //delay 1000ms


void loop() 

   int cm = ping(pingPin) ; 

   lcd.setCursor(0, 0);           // set the cursor to column 0, line 0

    lcd.print("     oku     ");// Print a message of "oku: "to the LCD.


    lcd.setCursor(0, 1);          // set the cursor to column 0, line 0

    lcd.print("distance: ");      // Print a message of "distance: "to the LCD.

    lcd.print(cm);                // Print a centigrade distance to the LCD. 

    lcd.print(" cm    ");         // Print the unit of the centigrade distance to the LCD.

   delay(500);

}

     

int ping(int pingPin) 

   // establish variables for duration of the pin, 

   // and the distance result in inches and centimeters: 

   long duration, cm; 

   // The PING))) is triggered by a HIGH pulse of 2 or more microseconds. 

   // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: 

   pinMode(trigPin, OUTPUT); 

   digitalWrite(trigPin, LOW); 

   delayMicroseconds(2); 

   digitalWrite(trigPin, HIGH); 

   delayMicroseconds(5); 

   digitalWrite(trigPin, LOW); 


   pinMode(pingPin, INPUT); 

   duration = pulseIn(pingPin, HIGH); 


   // convert the time into a distance 

   cm = microsecondsToCentimeters(duration); 

   return cm ; 


long microsecondsToCentimeters(long microseconds) 

   // The speed of sound is 340 m/s or 29 microseconds per centimeter. 

   // The ping travels out and back, so to find the distance of the 

   // object we take half of the distance travelled. 

   return microseconds / 29 / 2; 


Compile the program and upload to Arduino UNO board Now, change the distance between the ultrasonic module and the obstacle, and you will find the distance value displayed on the LCD1602 changed


19 August, 2019
0 Comment Leave Comments

In this tutorial we will learn how to use DHT-11 to collect temperature and humidity by programming Arduino.

Hardware required
1 * Arduino UNO
1 * USB Cable

1 * LCD1602

1 * 10kΩ Potentiometer

1 * DHT-11 Temperature and Humidity Sensor

1 * Breadboard 

Several jumper wires


Principle of operation

This DHT-11 temperature & humidity sensor features a temperature & humidity sensor complex with a calibrated digital signal output. By using the exclusive digital signal acquisition technique and temperature & humidity sensing technology, it ensures high reliability and excellent long-term stability. This sensor includes a resistive-type humidity measurement component and an NTC temperature measurement component, and connects to a high-performance 8-bit microcontroller, offering excellent quality, fast response, anti-interference ability and cost-effectiveness.

Note to include the library for  DHT-11 

Experiment code

//File name:   Experiment 18

/********************************

Description: you can see the temperature and humidity data

             displayed on the LCD1602.

*******************************/

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/19

#include <dht11.h>

#include <LiquidCrystal.h>

 

dht11 DHT11;

#define DHT11PIN 2

LiquidCrystal lcd(4, 6, 10, 11, 12, 13);  //Define the connection LCD pin  

void setup()

     lcd.begin(16, 2);    // set up the LCD's number of columns and rows: 

     lcd.clear();         //Clears the LCD screen and positions the cursor in the upper-left corner 

     delay(1000); //延时1000ms

}

 

void loop()

{

    int chk = DHT11.read(DHT11PIN);

    lcd.setCursor(0, 0); // set the cursor to column 0, line 0

    lcd.print("Humidity:");// Print a message of "Humidity: "to the LCD.

    lcd.print((float)DHT11.humidity, 2);// Print a message of "Humidity: "to the LCD.

    lcd.print(" % "); // Print the unit of the centigrade temperature to the LCD.

    

    lcd.setCursor(0, 1); // set the cursor to column 0, line 0

    lcd.print("Temp:    ");// Print a message of "Temp: "to the LCD.

    lcd.print((float)DHT11.temperature, 2);// Print a centigrade temperature to the LCD. 

    lcd.print(" C "); // Print the unit of the centigrade temperature to the LCD.

    delay(1000);     

}


Compile the program and upload to Arduino UNO board Now, you can see the temperature and humidity data displayed on the LCD1602.



18 August, 2019
0 Comment Leave Comments

In this tutorial, we will learn howto use an IR receiver toreceive signals from a remote controller. 


Hardware required
1 * Arduino UNO
1 * USB Cable 
1 * IR Receiver HX1838 
1 * Remote Controller 
1* Breadboard
Several jumper wires 


Principle of operation
The IR receiver HX1838 can receive signals from an infrared (IR) remote controller. It has only three pins: signal, VCC and GND. So it is simple to connect with an Arduino board.
In this experiment, we program the Arduino board to receive the infrared signals, and then send the received data to Serial Monitor. In the program, we use the Arduino-IRremote-master library (provided).
note
Before using this library, you have to delete the RobotIRremote directory in your Arduino IDE directory (check in IDE by File->Preferences, and see the path in the Browse dialog box), and delete the RobotIRremote directory in the system Documents folder. For example, if your computer is running on Windows 7, you need to delete the RobotIRremote directory in
C:\ P r o g r a m F il e s ( x 8 6 ) \ A r d ui n o \ li b r a ri e s

and

C: \ U s e r s \ S J G \ D o c u m e n t s \ A r d ui n o \ li b r a ri e s .
Otherwise, when you compile the program, errors will be prompted 


Experiment code

//File name:   Experiment 17

/********************************

Description:When you click the button on the remote control,

             you can see the serial montiol data.

*******************************/

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/18

#include <IRremote.h>


int RECV_PIN = 7;//The definition of the infrared receiver pin 7

IRrecv irrecv(RECV_PIN);

decode_results results;


void setup()

{

  Serial.begin(9600); //Open serial 

  irrecv.enableIRIn(); // Initialization infrared receiver


void loop() 

{

  if (irrecv.decode(&results)) {

    Serial.println(results.value, HEX);//Wrap output in hex receive code

    Serial.println();//For ease of viewing the output to add a blank line

    irrecv.resume(); //Receiving the next value

  }

}


Compile the program and upload to Arduino UNO board Now, press a button on the remote controller, and you will see the button number displayed on Serial Monitor.

18 August, 2019
0 Comment Leave Comments

In this tutorial, we will learn how to use a thermistor to collect the temperature data by programming Arduino. The information what a thermistor collects is displayed on the LCD1602. 

Hardware required

1 * Arduino UNO

1 * USB Cable 

1 * LCD1602

1 * 10kΩ Potentiometer

1 * 10kΩ Resistor

1 * Thermistor 

1* Breadboard

Several jumper wires 1

Principle of operation

A thermistor is a type of resistor whose resistance varies significantly with temperature,moresothaninstandardresistors.Inthisexperimentweusean MF52 NTC-type thermistor, and it is usually used as a temperature sensor. The key parameters of an MF52 thermistor: B-parameter: 3470. 25℃ resistance: 10kΩ.

note that there is a calculation  in relationship between the resistance of thermistor and temperature 

Experiment  code

//File name:   Experiment 16

/********************************

Description: The information which a thermistor collects 

             temperature is displayed on the LCD1602.The information which a thermistor collects 

             temperature is displayed on the LCD1602.

*******************************/

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/18

#include <LiquidCrystal.h>


int tim = 50;                       //the value of delay time

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(4, 6, 10, 11, 12, 13);

int thermistorPin = 0;           // thermistor connected to analog pin 3


void setup()

{

  lcd.begin(16, 2);    // set up the LCD's number of columns and rows: 

  lcd.clear();         //Clears the LCD screen and positions the cursor in the upper-left corner 

}


void loop() 

{

   float a = analogRead(thermistorPin);

  //the calculating formula of temperature

  float resistor = (1023.0*10000)/a-10000;

  float tempC = (3435.0/(log(resistor/10000)+(3435.0/(273.15+25)))) - 273.15;

  

  lcd.setCursor(0, 0); // set the cursor to column 0, line 0

  lcd.print("     adeept     ");// Print a message of "Temp: "to the LCD.

 

  lcd.setCursor(0, 1); // set the cursor to column 0, line 0

  lcd.print("  Temp: ");// Print a message of "Temp: "to the LCD.

  lcd.print(tempC);// Print a centigrade temperature to the LCD. 

  lcd.print(" C  "); // Print the unit of the centigrade temperature to the LCD.

  delay(500);

}

Compile the program and upload to Arduino UNO board Now, you can see the temperature collected by thermistor on the LCD1602.

18 August, 2019
0 Comment Leave Comments

In this tutorial, we will introduce a new electronic device(Servo) to you,and tell you how to control it with the Arduino UNO. 

Hardware required

1 * Arduino UNO

1 * USB Cable 

1 * servo motor

Principle of operation

  • Servo motor

The servo motor has three wires, power,ground and signal.The power wire is typically red,and should be connected to the 5V pin on the Arduino board.The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. Usually the signal pin is yellow,orange or white,and should be connected to a digital pin on the Arduino board. Note that the servo motor draws a considerable amount of power, if you need to drive more than one or two servos, you'll probably need to power them with an extra supply (i.e. not the +5V pin on your Arduino). Be sure to connect the grounds of the Arduino and external power supply together. 

  • Servo Library 

This library allows an Arduino board to control RC (hobby) servo motors. Servos have integrated gears and a shaft that can be precisely controlled. Standard servos allow the shaft to be positioned at various angles, usually between 0 and 180 degrees. Continuous rotation servos allow the rotation of the shaft to be set to various speeds.

  • Key function

attacth()

Attach the Servo variable to a pin. Note that in Arduino 0016 and earlier, the Servo library supports only servos on only two pins: 9 and 10

Syntax:

servo.attach(pin)

servo.attach(pin, min, max)

parameters

servo: a variable of type Servo

pin: the number of the pin that the servo is attached to min (optional):

the pulse width, in microseconds, corresponding to the minimum (0-degree) angle on the servo (defaults to 544) max (optional):

the pulse width, in microseconds, corresponding to the maximum (180-degree) angle on the servo (defaults to 2400) 

Experiment  code

//File name:   Experiment 15

/********************************

Description:  The servo motor are rotated to 15 degrees, 30

             degrees, 45 degrees, 60 degrees, 75 degrees,

             90 degrees, 75 degrees, 60 degrees, 45 degrees,

             30 degrees, 15 degrees, 0 degrees, and then from

             0 degrees to 180 degrees and from 180 degrees to

             0 degrees.

*******************************/

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/18

#include <Servo.h>

Servo myservo;//create servo object to control a servo


void setup()

{

  myservo.attach(9);//attachs the servo on pin 9 to servo object

  myservo.write(0);//back to 0 degrees

  delay(1000);//wait for a second

}


void loop()

{

  myservo.write(15);//goes to 15 degrees

  delay(1000);//wait for a second


  myservo.write(30);//goes to 30 degrees

  delay(1000);//wait for a second.33


  myservo.write(45);//goes to 45 degrees

  delay(1000);//wait for a second.33


  myservo.write(60);//goes to 60 degrees

  delay(1000);//wait for a second.33


  myservo.write(75);//goes to 75 degrees

  delay(1000);//wait for a second.33


  myservo.write(90);//goes to 90 degrees

  delay(1000);//wait for a second


  myservo.write(75);//back to 75 degrees

  delay(1000);//wait for a second.33


  myservo.write(60);//back to 60 degrees

  delay(1000);//wait for a second.33


  myservo.write(45);//back to 45 degrees

  delay(1000);//wait for a second.33


  myservo.write(30);//back to 30 degrees

  delay(1000);//wait for a second.33


  myservo.write(15);//back to 15 degrees

  delay(1000);//wait for a second


  myservo.write(0);//back to 0 degrees

  delay(1000);//wait for a second

  for (int num = 0; num <= 180; num++)

  {

    myservo.write(num);//back to 'num' degrees(0 to 180)

    delay(10);//control servo speed

  }

  for (int num = 180; num >= 0; num--)

  {

    myservo.write(num);//back to 'num' degrees(180 to 0)

    delay(10);//control servo speed

  }

}

 Compile the program and upload to Arduino UNO board Now, you should see the servo rotate from 0 to 180 degrees, and then do it in the opposite direction.
18 August, 2019
0 Comment Leave Comments

In this tutorial, we will program the Arduino UNO to make a simple counter

Hardware required

1 * Arduino UNO

1 * USB Cable 

1 * 220Ω Resistor 

1 *4-digit 7-segment Display

1 * Breadboard 

Several jumper wires 

Principle of operation

The 4-digit segment display is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. 4-digit segment displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information. The 4-digit segment display is a 4*8-shaped LED display device composed of 32 LEDs (including four decimal points). The segments are named respectively a, b, c, d, e, f, g, h, dig1, dig2, dig3, and dig4.

What we use in this experiment is a common cathode 4-digit 7-segment display

Principle  code

//File name:   Experiment 14

//Description:  Simple Counter .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/18

int btn1pin=0;             //Set the digital 0 to button interface 

int btn2pin=13;            //Set the digital 13 to button interface 

int a = 1;

int b = 2;

int c = 3;

int d = 4;

int e = 5;

int f = 6;

int g = 7;

int p = 8;

int d4 = 9;

int d3 = 10;

int d2 = 11;

int d1 = 12;


long n = 0;

int x = 100;

int del = 55;  

int i = 0;

int j = 1;

int k = 2;

int l = 3;

int data;

void setup()

{

  pinMode(btn1pin,INPUT_PULLUP); //Set digital 2 port mode, the INPUT for the input

  pinMode(btn2pin,INPUT_PULLUP); //Set digital 2 port mode, the INPUT for the input

  pinMode(d1, OUTPUT);

  pinMode(d2, OUTPUT);

  pinMode(d3, OUTPUT);

  pinMode(d4, OUTPUT);

  pinMode(a, OUTPUT);

  pinMode(b, OUTPUT);

  pinMode(c, OUTPUT);

  pinMode(d, OUTPUT);

  pinMode(e, OUTPUT);

  pinMode(f, OUTPUT);

  pinMode(g, OUTPUT);

  pinMode(p, OUTPUT);

}

 

void loop()

{

  int d1,d2,d3,d4;

  if(digitalRead(btn1pin)==LOW)          //Detection button interface to low

  {   

      delay(10);                         //Delay 10ms for the elimination of key leading-edge jitter

      if(digitalRead(btn1pin)==LOW)      //Confirm button is pressed

      {     

        if(data>9999)                    

        { 

          data=9999;

        }else{

          data = data + 1;

        }

      }

   }

   if(digitalRead(btn2pin)==LOW)          //Detection button interface to low

  {   

      delay(10);                        //Delay 10ms for the elimination of key leading-edge jitter

      if(digitalRead(btn2pin)==LOW)      //Confirm button is pressed

      {     

        if(data<=0)

        { 

          data=0;

        }else{

          data = data - 1;

        }

      }

   }

   d1 = data/1000%10;    //The one thousand digital data

   d2 = data/100%10;     //The one hundred digital data

   d3 = data/10%10;      //Ten-digit data

   d4 = data%10;         //data of single digit

  for(int m=0;m<80;m++){

  clearLEDs();           //Turn off all LED lights

  pickDigit(1);          //Selection of a digital display

  pickNumber(d1);        //Display digital d1

  delayMicroseconds(200);

 

  clearLEDs();           //Turn off all LED lights

  pickDigit(2);          //Select the first two digital display

  pickNumber(d2);        //Display digital d2

  delayMicroseconds(200);

 

  clearLEDs();           //Turn off all LED lights

  pickDigit(3);          //Select the first three digital display

  //dispDec(3);          //Decimal display

  pickNumber(d3);        //Display digital d3

  delayMicroseconds(200);

  

  clearLEDs();           //Turn off all LED lights

  pickDigit(4);          //Select the first four digital display

  pickNumber(d4);        //Display digital d4

  delayMicroseconds(200);

  }

}

 

void pickDigit(int x)  //Defined pickDigit (x), whose role is to open the port dx

{

  digitalWrite(d1, HIGH);

  digitalWrite(d2, HIGH);

  digitalWrite(d3, HIGH);

  digitalWrite(d4, HIGH);

  switch(x)

  {

    case 1: 

           digitalWrite(d1, LOW); 

           break;

    case 2: 

           digitalWrite(d2, LOW); 

           break;

    case 3: 

           digitalWrite(d3, LOW); 

           break;

    default: 

           digitalWrite(d4, LOW); 

           break;

  }

}

 

void pickNumber(int x)   //Defined pickNumber (x), whose role is to display digital x

{

  switch(x)

  {

    case 1: 

           one(); 

           break;

    case 2: 

           two(); 

           break;

    case 3: 

           three(); 

           break;

    case 4: 

           four(); 

           break;

    case 5: 

           five(); 

           break;

    case 6: 

           six(); 

           break;

    case 7: 

   seven(); 

   break;

    case 8: 

   eight(); 

   break;

    case 9: 

   nine(); 

   break;

    default: 

           zero(); 

           break;

  }

}

 

void dispDec(int x)  //Decimal point setting Open

{

  digitalWrite(p, HIGH);

}

 

void clearLEDs()  //Clear screen

{

  digitalWrite(a, LOW);

  digitalWrite(b, LOW);

  digitalWrite(c, LOW);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

  digitalWrite(p, LOW);

}

 

void zero()  //Define those figures 0 cathode pin switch

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, HIGH);

  digitalWrite(g, LOW);

}

 

void one()  //Define those figures 1 cathode pin switch

{

  digitalWrite(a, LOW);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

}

 

void two()  //Define those figures 2 cathode pin switch

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, LOW);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, LOW);

  digitalWrite(g, HIGH);

}

 

void three()  //Define those figures 3 cathode pin switch

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, HIGH);

}

 

void four()  //Define those figures 4 cathode pin switch

{

9 August, 2019
0 Comment Leave Comments

Experiment description 13

In this tutorial, we will program the Arduino to achieve the controlling of a segment display. 

Hardware required

1 * Arduino UNO

1 * USB Cable 

1 * 220Ω Resistor 

1 * 7-segment Display 

1 * Breadboard 

Several jumper wires 

Principle of operation

The seven-segment display is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. Seven-segment displays are widely used in digital clocks, electronic meters, basic calculators, and other electronic devices that display numerical information. The seven-segment display is an 8-shaped LED display device composed of eight LEDs (including a decimal point).The segments respectively named a,b, c, d, e, f, g, and dp. The segment display can be divided into two types: common anode and common cathode segment displays, by internal connections.

For a common-anode LED, the common anode should be connected to the power supply(VCC);for a common-cathode LED,the common cathode should be connected to the ground (GND).
Each segment of a segment display is composed of an LED, so a resistor is needed for protecting the LED. A 7-segment display has seven segments for displaying a figure and one more for displaying a decimal point. For example,if you want to display a number'1', you should only light the segment b and c, as shown below.
 Code

//File name:   Experiment 13

//Description:  Segment display Numbers 0 to 9 .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/08 

int a=7; //definition digital 7  pins as pin to control 'a' section(segment)

int b=6; //definition digital 6  pins as pin to control 'b' section(segment)

int c=4; //definition digital 4  pins as pin to control 'c' section(segment)

int d=11;//definition digital 11 pins as pin to control 'd' section(segment)

int e=10;//definition digital 10 pins as pin to control 'e' section(segment)

int f=8; //definition digital 8  pins as pin to control 'f' section(segment)

int g=9; //definition digital 9  pins as pin to control 'g' section(segment)

int dp=5;//definition digital 5  pins as pin to control 'dp' section(segment)

void digital_0(void) //Segment display digital 0

{

  digitalWrite(a,HIGH);

  digitalWrite(b,HIGH);

  digitalWrite(c,HIGH);

  digitalWrite(d,HIGH);

  digitalWrite(e,HIGH);

  digitalWrite(f,HIGH);

  digitalWrite(g, LOW);

  digitalWrite(dp,LOW);

}

void digital_1(void) //Segment display digital 1

{

  digitalWrite(a,LOW);

  digitalWrite(b,HIGH);

  digitalWrite(c,HIGH);

  digitalWrite(d,LOW);

  digitalWrite(e,LOW);

  digitalWrite(f,LOW);

  digitalWrite(g,LOW);

  digitalWrite(dp,LOW);

}

void digital_2(void) //Segment display digital 2

{

  digitalWrite(a,HIGH);

  digitalWrite(b,HIGH);

  digitalWrite(c,LOW);

  digitalWrite(d,HIGH);

  digitalWrite(e,HIGH);

  digitalWrite(f,LOW);

  digitalWrite(g,HIGH);

  digitalWrite(dp,LOW);

}

void digital_3(void) //Segment display digital 3

{

  digitalWrite(a,HIGH);

  digitalWrite(b,HIGH);

  digitalWrite(c,HIGH);

  digitalWrite(d,HIGH);

  digitalWrite(e,LOW);

  digitalWrite(f,LOW);

  digitalWrite(g,HIGH);

  digitalWrite(dp,LOW);

}

void digital_4(void) //Segment display digital 4

{

  digitalWrite(a,LOW);

  digitalWrite(b,HIGH);

  digitalWrite(c,HIGH);

  digitalWrite(d,LOW);

  digitalWrite(e,LOW);

  digitalWrite(f,HIGH);

  digitalWrite(g,HIGH);

  digitalWrite(dp,LOW);

}

void digital_5(void) //Segment display digital 5

{

  digitalWrite(a,HIGH);

  digitalWrite(b,LOW);

  digitalWrite(c,HIGH);

  digitalWrite(d,HIGH);

  digitalWrite(e,LOW);

  digitalWrite(f,HIGH);

  digitalWrite(g,HIGH);

  digitalWrite(dp,LOW);

}

void digital_6(void) //Segment display digital 6

{

  digitalWrite(a,HIGH);

  digitalWrite(b,LOW);  

  digitalWrite(c,HIGH);

  digitalWrite(d,HIGH);

  digitalWrite(e,HIGH);

  digitalWrite(f,HIGH);

  digitalWrite(g,HIGH);

  digitalWrite(dp,LOW);

}

void digital_7(void) //Segment display digital 7

{

  digitalWrite(a,HIGH);

  digitalWrite(b,HIGH);  

  digitalWrite(c,HIGH);  

  digitalWrite(d,LOW); 

  digitalWrite(e,LOW);

  digitalWrite(f,LOW);

  digitalWrite(g,LOW);

  digitalWrite(dp,LOW);

}

void digital_8(void) //Segment display digital 8

{

  digitalWrite(a,HIGH);

  digitalWrite(b,HIGH);

  digitalWrite(c,HIGH);

  digitalWrite(d,HIGH);

  digitalWrite(e,HIGH);

  digitalWrite(f,HIGH);

  digitalWrite(g,HIGH);

  digitalWrite(dp,LOW);

}

void digital_9(void) //Segment display digital 9

{

  digitalWrite(a,HIGH);

  digitalWrite(b,HIGH);

  digitalWrite(c,HIGH);

  digitalWrite(d,HIGH);

  digitalWrite(e,LOW);

  digitalWrite(f,HIGH);

  digitalWrite(g,HIGH);

  digitalWrite(dp,LOW);

}

void setup()

{

  int i;             //Define variables

  for(i=4;i<=11;i++)

  pinMode(i,OUTPUT); //Set up 4 ~ 11 pins to output mode

}

void loop()

{

  digital_0(); //Segment display digital 0

  delay(1000); //Delay 1s

  digital_1(); //Segment display digital 1

  delay(1000); //Delay 1s

  digital_2(); //Segment display digital 2

  delay(1000); //Delay 1s

  digital_3(); //Segment display digital 3

  delay(1000); //Delay 1s

  digital_4(); //Segment display digital 4

  delay(1000); //Delay 1s

  digital_5(); //Segment display digital 5

  delay(1000); //Delay 1s

  digital_6(); //Segment display digital 6

  delay(1000); //Delay 1s

  digital_7(); //Segment display digital 7

  delay(1000); //Delay 1s

  digital_8(); //Segment display digital 8

  delay(1000); //Delay 1s

  digital_9(); //Segment display digital 8

  delay(1000); //Delay 1s

}


Compile the program and upload to Arduino UNO board Now,you should see the number 0~9 and characters A~F displayed in turn on the segment display.



9 August, 2019
0 Comment Leave Comments

Experiment description 12

In this tutorial, we will learn how make a simple voltmeter (0~5V) with Arduino UNO and LCD1602. Then, we will measure the voltage of the potentiometer(when adjusting the knob) with the simple voltmeter and display the voltage detected on the LCD1602. 

Hardware required

 1 * Arduino UNO

1 * USB Cable

1 * LCD1602

2 * 10kΩ Potentiometer

1 * Breadboard

Principle of operation

The basic principle of this experiment: Convert the analog voltage collected from Arduino to digital quantity by the ADC (analog-to-digital converter) through programming, and then display the voltage on the LCD1602. Connect the three wires from the potentiometer to your Arduino board. The first goes to ground from one of the outer pins of the potentiometer. The second goes from analog input 0 to the middle pin of the potentiometer. The third goes from 5V to the other outer pin of the potentiometer. 

By turning the shaft of the potentiometer, you change the resistance on either side of the wiper which is connected to the center pin of the potentiometer. This changes the voltage at the center pin. When the resistance between the middle and the side one (connected to 5V) is close to zero (and the resistance ontheothersideis closeto10kOhm), thevoltageatthemiddlepiniscloseto 5V. When the resistances are reversed, the voltage at the center pin changes to about 0V, or ground. This voltage is the analog voltage that you're reading as an input. 

The Arduino UNO board has a circuit inside called an analog-to-digital converter that reads this changing voltage and converts it to a number between 0 and 1023. When the shaft is turned all the way in one direction, there are 0 volts going to the pin, and the input value is 0. When the shaft is done in the opposite direction, it's 5 volts going to the pin and the input value is 1023. In between, analogRead( ) returns a number between 0 and 1023 that is proportional to the amount of voltage being applied to the pin. 
Keyfunction :

● analogRead() 
Reads the value from the specified analog pin. The Arduino board contains a 6 channel (8 channels on the Mini and Nano, 16 on the Mega), 10-bit analog to digital converter. This means that it will map input voltages between 0 and 5 voltsintointegervaluesbetween0 and1023.This yieldsaresolutionbetween readings of: 5 volts / 1024 units or, 0.0049 volts (4.9 mV) per unit. The input range and resolution can be changed using analogReference( ).

It takes about 100 microseconds (0.0001 s) to read an analog input, so the maximum reading rate is about 10,000 times a second. 

Syntax :

analogRead(pin)

Parameters:

pin: the number of the analog input pin to read from (0 to 5 on most boards, 0 to 7 on the Mini and Nano, 0 to 15 on the Mega)

Returns :

int (0 to 1023)

Experiment Code

//File name:   Experiment 12

//Description:  how to display text on LCD1602 Display  .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/08 


#include <LiquidCrystal.h>

char array1[]="Oku Voltmeter                  ";  //the string to print on the LCD

char array2[]=" Voltage: 0.00V                   ";  //the string to print on the LCD


// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(4, 6, 10, 11, 12, 13);

int photoresistorPin = 0;  // potentiometer wiper (middle terminal) connected to analog pin 3

int val=0;

int tim = 50;              //the value of delay time


void setup()

{

  lcd.begin(16, 2);    // set up the LCD's number of columns and rows: 

  lcd.clear();         //Clears the LCD screen and positions the cursor in the upper-left corner 

  lcd.setCursor(0,0);  // set the cursor to column 15, line 0

  for (int positionCounter1 = 0; positionCounter1 < 16; positionCounter1++)

  {

      lcd.print(array1[positionCounter1]);  // Print a message to the LCD.

      delay(tim);      //wait for 250 microseconds

  }

}


void loop() 

{

   val = analogRead(photoresistorPin)*(5.0 / 1023.0)*100;//Data collection

   array2[10]  = val/100%10+0x30;//Take one hundred - bit data

   array2[12] = val/10%10+0x30;  //Take ten-bit data

   array2[13] = val%10+0x30;     //Take a bit of data

   lcd.setCursor(0,1);           //Set the cursor to column 15, line 1

   for (int positionCounter3 = 0; positionCounter3 < 26; positionCounter3++)

   {

     lcd.print(array2[positionCounter3]);  // Print a message to the LCD.

     delay(tim);                 //Wait for 250 microseconds

   }

}

Compile the program and upload to Arduino UNO. Now, turn the shaft of the potentiometer, and you will see the voltage displayed on the LCD1602 changed

9 August, 2019
0 Comment Leave Comments

Experiment 11

In this tutorial, we will learn how to use a character display device - LCD1602 on the Arduino platform. We first make the LCD1602 display a string "Hello World!" scrolling, and then "Oku" and “www.okuelectronics.com” statically

Hardware required

 1 * Arduino UNO

1 * USB Cable

1 * LCD1602

1 * 10kΩ Potentiometer

1 * Breadboard

Several jumper wires 

Principle of operation

LCD1602 is a kind of character LCD display. The LCD has a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display. The interface consists of the following pins: 

● A register select (RS) pin that controls where in the LCD's memory you're writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD's controller looks for instructions on what to do next. 

● A Read/Write (R/W) pin that selects reading mode or writing mode 

● An Enable pin that enables writing to the registers 

● 8 data pins (D0-D7). The state of these pins (high or low) is the bits that you're writing to a register when you write, or the values when you read. 

● Therearealsoadisplaycontrastpin(Vo),powersupplypins(+5VandGnd) and LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on or off the LED backlight respectively. 

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal Library simplifies this for you so you don't need to know the low-level instructions.
The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I/O pins from the Arduino, while the 8-bit mode requires 11 pins. For displaying text on the screen,you can do most everything in 4-bit mode, so example shows how to control a 2x16 LCD in 4-bit mode. 

A potentiometer , informally a pot, is athree-terminal resistorwith asliding or rotating contact that forms an adjustable voltage divider. If only twoterminals are used, one end and the wiper, it acts as a variable resistor or rheostat

Keyfunction :

●begin()

Specifies the dimensions (width and height) of the display.

Syntax : lcd.begin(cols, rows)

Parameters: 
lcd: a variable of type LiquidCrystal

cols: the number of columns that the display has

rows: the number of rows that the display has

●setCursor() Position the LCD cursor; that is, set the location at which subsequent text written to the LCD will be displayed.

Syntax :

lcd.setCursor(col, row)

Parameters :

lcd: a variable of type LiquidCrystal

col: the column at which toposition the cursor (with 0 being the first column)

row: the row at which to position the cursor (with 0 being the first row)

●scrollDisplayLeft()

Scrolls the contents of the display (text and cursor) one space to the left.

Syntax lcd.scrollDisplayLeft()

Parameters :

lcd: a variable of type LiquidCrystal

Example

scrollDisplayLeft() and scrollDisplayRight()

See also

scrollDisplayRight()
●print()

Prints text to the LCD.

Syntax :

lcd.print(data)

lcd.print(data, BASE)

Parameters :

lcd: a variable of type LiquidCrystal

data: the data to print (char, byte, int, long, or string)

BASE (optional): the base in which to print numbers: BIN for binary (base 2),

DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).

Returns :

byte

print() will return the number of bytes written, though reading that number is optional

●clear()

Clears the LCD screen and positions the cursor in the upper-left corner.

Syntax :

lcd.clear()

Parameters :

lcd: a variable of type LiquidCrystal 


Experiment code

//File name:   Experiment 11

//Description:  how to display text on LCD1602 Display  .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/08 

#include <LiquidCrystal.h>

char array1[]="     Oku     ";                //the string to print on the LCD

char array2[]="  hello world!               ";  //the string to print on the LCD

char array3[]=" www.okuelectronics.com ";                //the string to print on the LCD

int tim = 250;  //the value of delay time

// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(4, 6, 10, 11, 12, 13);

void setup()

{

  lcd.begin(16, 2);  // set up the LCD's number of columns and rows: 

}

void loop() 

{

    lcd.clear();  //Clears the LCD screen and positions the cursor in the upper-left corner

    lcd.setCursor(15,0);                   // set the cursor to column 15, line 1

    for (int positionCounter2 = 0; positionCounter2 < 30; positionCounter2++)

    {

      lcd.scrollDisplayLeft();             //Scrolls the contents of the display one space to the left.

      lcd.print(array2[positionCounter2]); // Print a message to the LCD.

      delay(tim);                          //wait for 250 microseconds

    }

    lcd.clear();  //Clears the LCD screen and positions the cursor in the upper-left corner.   

 

   lcd.setCursor(0,0);                    // set the cursor to column 15, line 0

    for (int positionCounter1 = 0; positionCounter1 < 16; positionCounter1++)

    {

      lcd.print(array1[positionCounter1]); // Print a message to the LCD.

      delay(tim);                          //wait for 250 microseconds

    }

    

    lcd.setCursor(0,1);                    // set the cursor to column 15, line 1

    for (int positionCounter3 = 0; positionCounter3 < 16; positionCounter3++)

    {

      lcd.print(array3[positionCounter3]); // Print a message to the LCD.

      delay(tim);                          //wait for 250 microseconds

    }

}

 Compile the program and upload to Arduino UNO board Now, you can see the string "Hello Wordl!" shown on the LCD1602 scrolling, and then the string "Oku" and "www.okuelectronics.com" displayed statically.









9 August, 2019
0 Comment Leave Comments

Experiment 10

In this tutorial, we will program the Arduino to control a passive buzzer, and then make it play some music. .

Hardware required

1 * Arduino UNO

1 * USB Cable

1 * NPN Transistor (8050)

1 * 1kΩ Resistor

1 * Passive Buzzer

1 * LED

1 * 220Ω Resistor

1 * Breadboard

Several jumper wires 

Principle of operation

As long as you send some square wave signals to a passive buzzer with different frequencies, the buzzer will make different sounds accordingly

Keyfunction :

●tone()

Generates a square wave of the specified frequency(and 50%duty cycle) on a pin. A duration can be specified, otherwise the wave continues until a call to noTone(). The pin can be connected to a piezo buzzer or other speaker to play tones. Only one tone can be generated at a time. If a tone is already playing on a different pin, the call to tone() will have no effect. If the tone is playing on the same pin, the call will set its frequency. Use of the tone() function will interfere with PWM output on pins 3 and 11 (on boards other than the Mega).

NOTE: if you want to play different pitches on multiple pins, you need to call noTone() on one pin before calling tone() on the next pin. 

Syntax:

tone(pin, frequency)

tone(pin, frequency, duration) 

Parameters :

pin: the pin on which to generate the tone

frequency: the frequency of the tone in hertz - unsigned int

duration: the duration of the tone in milliseconds (optional) - unsigned long

Returns:

nothing 
●noTone()

Stops the generation of a square wave triggered by tone(). Has no effect if no tone is being generated.

NOTE: if you want to play different pitches on multiple pins, you need to call noTone() on one pin before calling tone() on the next pin.

Syntaxs :

noTone(pin)

Parameters: pin: the pin on which to stop generating the tone

Returns :

nothing

Experiment code

//File name:   Experiment 10

//Description:  LED Bar Graph Display  .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/06/08 

#define NTD0 -1                    //bass  1#   2#   3#   4#   5#   6#   7# 

#define NTD1 294                   // A    221  248  278  294  330  371  416 

#define NTD2 330                   // B    248  278  294  330  371  416  467

#define NTD3 350                   // C    131  147  165  175  196  221  248

#define NTD4 393                   // D    147  165  175  196  221  248  278

#define NTD5 441                   // E    165  175  196  221  248  278  312

#define NTD6 495                   // F    175  196  221  234  262  294  330

#define NTD7 556                   // G    196  221  234  262  294  330  371

                                   

#define NTDL1 147                  //Alto  1    2    3    4    5    6    7

#define NTDL2 165                  // A    441  495  556  589  661  742  833

#define NTDL3 175                  // B    495  556  624  661  742  833  935

#define NTDL4 196                  // C    262  294  330  350  393  441  495

#define NTDL5 221                  // D    294  330  350  393  441  495  556

#define NTDL6 248                  // E    330  350  393  441  495  556  624

#define NTDL7 278                  // F    350  393  441  495  556  624  661  

                                   // G    393  441  495  556  624  661  742

#define NTDH1 589

#define NTDH2 661                  //high pitch  1#   2#   3#   4#   5#   6#   7#  

#define NTDH3 700                  //    A       882  990  1112 1178 1322 1484 1665   

#define NTDH4 786                  //    B       990  1112 1178 1322 1484 1665 1869 

#define NTDH5 882                  //    C       525  589  661  700  786  882  990

#define NTDH6 990                  //    D       589  661  700  786  882  990  1112

#define NTDH7 112                  //    E       661  700  786  882  990  1112 1248

//c pinlv                          //    F       700  786  882  935  1049 1178 1322

#define WHOLE 1                    //    G       786  882  990  1049 1178 1322 1484

#define HALF 0.5

#define QUARTER 0.25

#define EIGHTH 0.25

#define SIXTEENTH 0.625


int tune[]=      //Music tones

{

  NTD3,NTD3,NTD4,NTD5,

  NTD5,NTD4,NTD3,NTD2,

  NTD1,NTD1,NTD2,NTD3,

  NTD3,NTD2,NTD2,

  NTD3,NTD3,NTD4,NTD5,

  NTD5,NTD4,NTD3,NTD2,

  NTD1,NTD1,NTD2,NTD3,

  NTD2,NTD1,NTD1,

  NTD2,NTD2,NTD3,NTD1,

  NTD2,NTD3,NTD4,NTD3,NTD1,

  NTD2,NTD3,NTD4,NTD3,NTD2,

  NTD1,NTD2,NTDL5,NTD0,

  NTD3,NTD3,NTD4,NTD5,

  NTD5,NTD4,NTD3,NTD4,NTD2,

  NTD1,NTD1,NTD2,NTD3,

  NTD2,NTD1,NTD1

};

float durt[]= //Each musical tone delay time

{

  1,1,1,1,

  1,1,1,1,

  1,1,1,1,

  1+0.5,0.5,1+1,

  1,1,1,1,

  1,1,1,1,

  1,1,1,1,

  1+0.5,0.5,1+1,

  1,1,1,1,

  1,0.5,0.5,1,1,

  1,0.5,0.5,1,1,

  1,1,1,1,

  1,1,1,1,

  1,1,1,0.5,0.5,

  1,1,1,1,

  1+0.5,0.5,1+1,

};

int length;

int tonepin=10;  //Buzzer connected digital pin 10

int ledp=2;     //LED connected digital pin 2

void setup()

{

  pinMode(tonepin,OUTPUT); //Digital pin 10 output mode

  pinMode(ledp,OUTPUT);    //Digital pin 2 output mode

  length=sizeof(tune)/sizeof(tune[0]);//Calculate the total number of musical tones

}

void loop()

  for(int x=0;x<length;x++)

  {

    tone(tonepin,tune[x]);    //Open buzzer

    digitalWrite(ledp, HIGH); //LED On

    delay(400*durt[x]);       //Tone Delay. Note:400 can be replaced

    digitalWrite(ledp, LOW);  //LED Off

    delay(100*durt[x]);       //Tone Delay. Note:100 can be replaced

    noTone(tonepin);          //Turn off the buzzer

  }  

  delay(2000);                //delay 2S

}

Compile the program and upload to Arduino UNO board Now, you can hear the passive buzzer play music, with the LED blinking.

9 August, 2019
0 Comment Leave Comments

Experimental 9

In this lesson, we will program the Arduino UNO for  RGB LED control, and make RGB LED emits a various of colors of light. 

Hardware Required

 1 * Arduino UNO

1 * USB Cable

1 * RGB LED

3* 220Ω Resistor

1 * Breadboard

Several jumper wires 

Principle of operation

RGB LEDs consist of three LEDs: red, green and blue. These three colored LEDs are capable of producing any color. Tri-color LEDs with red, green, and blue emitters, in general using a four-wire connection with one common lead (anode or cathode).

What we use in this experiment is a common anode RGB LED. The longest pin is the common anode of the three LEDs.The pin is connected to the+5Vpin of the Arduino, and the rest pins are connected to pin D9, D10, and D11 of the Arduino with a current limiting resistor between.

Experiment Code

//File name:   Experiment 9

//Description: make RGB LED emits a various of colors of light.

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/08 

int redPin = 6;   // R petal on RGB LED module connected to digital pin 6 
int greenPin = 4; // G petal on RGB LED module connected to digital pin 4 
int bluePin = 3;   // B petal on RGB LED module connected to digital pin 3
void setup()    
{   
   pinMode(redPin, OUTPUT);   // sets the redPin to be an output 
   pinMode(greenPin, OUTPUT); // sets the greenPin to be an output 
   pinMode(bluePin, OUTPUT);  // sets the bluePin to be an output 
}    
void loop()  // run over and over again  
{    
    // Basic colors:  
    color(255, 0, 0); // turn the RGB LED red  
    delay(1000);      // delay for 1 second  
    color(0,255, 0);  // turn the RGB LED green  
    delay(1000);      // delay for 1 second  
    color(0, 0, 255); // turn the RGB LED blue
    delay(1000);      // delay for 1 second  
  
    // Example blended colors:  
    color(255,255,0);   // turn the RGB LED yellow   
    delay(1000);        // delay for 1 second  
    color(255,255,255); // turn the RGB LED white  
    delay(1000);        // delay for 1 second  
    color(128,0,255);   // turn the RGB LED purple  
     delay(1000);       // delay for 1 second  
     color(0,0,0);      // turn the RGB LED off  
     delay(1000);       // delay for 1 second  
}     
     
void color (unsigned char red, unsigned char green, unsigned char blue)// the color generating function  
{    
     analogWrite(redPin, 255-red);     // PWM signal output   
     analogWrite(greenPin, 255-green); // PWM signal output
     analogWrite(bluePin, 255-blue);   // PWM signal output
}     

Compile the program and upload to Arduino UNO board Now,you can see the RGB LED flash red, green,blue,yellow,white and purple light, and then go out. Each state lasts for 1s each time, and the LED flashes colors repeatedly in such sequence.


9 August, 2019
0 Comment Leave Comments

Experiment 8

In this tutorial, we will learn how to program the Arduino to generate PWM signals

Hardware required

 1 * Arduino UNO

1 * USB Cable

1 * LED

1 * 220Ω Resistor

1 * Breadboard

Several jumper wires 

Principle of operation

Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signals witched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration  of"on time" is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED. In the following figure, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.

Keyfunction :

●analogWrite()

Writes an analog value (PWM wave) to a pin. Can be used to light an LED at varying brightnesses or drive a motor at various speeds. After a call to analogWrite(),the pin will generate a steady square wave of the specified duty cycle until the next call to analogWrite() (or a call to digitalRead() or digitalWrite() on the same pin). You do not need to call pinMode() to set the pin as an output before calling analogWrite(). 

Syntax :

analogWrite(pin, value)

Parameters:

pin: the pin to write to.

value: the duty cycle: between 0 (always off) and 255 (always on).

Returns :

nothing

Experiment code

//File name:   Experiment 8

//Description:  program Arduino to generate PWM signals  .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/08/08 

int ledpin=5; //definition digital 11 pins as pin to control the LED

void setup ()

{

  pinMode(ledpin,OUTPUT); //Set digital 5 port mode, the OUTPUT for the output

}

void loop()

{

   for (int a=0; a<=255;a++)  //Loop, PWM control of LED brightness increase

   {

     analogWrite(ledpin,a);   //PWM output value a (0~255)

     delay(15);                //The duration of the current brightness level. 15ms           

   }

   for (int a=255; a>=0;a--)  //Loop, PWM control of LED brightness Reduced

   {

     analogWrite(ledpin,a);   //PWM output value a (255~0)

     delay(15);                //The duration of the current brightness level. 15ms 

   }

   delay(100);                //100ms delay

}


 Compile the program and upload to Arduino UNO board. Now, you should see the LED lights up and gets gradually brighter, and then slowly turns dimmer. The process repeats circularly, and with the particular rhythm it looks like animals' breath


7 August, 2019
1 Comment Leave Comments

Experiment 7

In this tutorial, we will learn how to control an LED bar graph by programming the Arduino.

Hardware required

1 * Arduino UNO

1 * USB Cable

1 * 10kΩ Potentiometer

10 * 220Ω Resistor

1 * LED Bar Graph

1 * Breadboard

Several jumper wires

Principle of operation

The bar graph - a series of LEDs in a line, as you can see on an audio display, is a common hardware display for analog sensors. It's made up of a series of LEDs in a row, an analog input like a potentiometer, and a little code in between.Youcanbuymulti-LEDbargraphdisplaysfairly cheaply.Thistutorial demonstrates how to control a series of LEDs in a row, but can be applied to any series of digital outputs. 

The sketch works like this: first read the input. Map the input to the output rangewhich is 0-10in this casesince tenLEDsareused.Thenyousetupa f o r loop to iterate over the outputs. If the number in the array of the output is lower than the mapped input minimum, it is turned on. If not, it's off

A potentiometer, informally a pot, is a three-terminal resistor with a sliding or rotating contact that forms an adjustable voltage divider. If only twoterminals are used, one end and the wiper, it acts as a variable resistor or rheostat. 

Experiment code

//File name:   Experiment 7

//Description:  LED Bar Graph Display  .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/06/08 

int pin1 = 1;
int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;           //definition digital 10 pins as pin to control the LED

int potentiometerPin = 0; // potentiometer connected to analog pin 3

void setup()
{
  pinMode(pin1,OUTPUT);    //Set the digital 1 port mode, OUTPUT: Output mode
  pinMode(pin2,OUTPUT);    //Set the digital 2 port mode, OUTPUT: Output mode
  pinMode(pin3,OUTPUT);    //Set the digital 3 port mode, OUTPUT: Output mode
  pinMode(pin4,OUTPUT);    //Set the digital 4 port mode, OUTPUT: Output mode
  pinMode(pin5,OUTPUT);    //Set the digital 5 port mode, OUTPUT: Output mode
  pinMode(pin6,OUTPUT);    //Set the digital 6 port mode, OUTPUT: Output mode
  pinMode(pin7,OUTPUT);    //Set the digital 7 port mode, OUTPUT: Output mode
  pinMode(pin8,OUTPUT);    //Set the digital 8 port mode, OUTPUT: Output mode
  pinMode(pin9,OUTPUT);    //Set the digital 9 port mode, OUTPUT: Output mode
  pinMode(pin10,OUTPUT);    //Set the digital 10 port mode, OUTPUT: Output mode
}

void loop() 
{
   float a = analogRead(potentiometerPin);//Read the voltage photoresistance
   a = map(a,0,1023,0,11);    //Photoresistor voltage value converted from 0-1023 to 0-11
   for(int i=1;i<=a;i++){
      digitalWrite(i,LOW);    //HIGH is set to about 5V PIN8
   }
   for(int j=10;j>a;j--){
      digitalWrite(j,HIGH);   //HIGH is set to about 5V PIN8
   }   
   delay(50);                 //delay 50ms
}


Compile the program and upload to Arduino UNO board Now,turn the knob of the potentiometer,and you will see the number ofLEDs in the LED bar graph changed


7 August, 2019
0 Comment Leave Comments

Experimental 6

In this lesson, we will program the Arduino UNO to make an LED flowing blink by sequence from the red one on the right side to others on the left.

Hardware Required

1 * Arduino UNO

1 * USB Cable

8 * LED

8 * 220Ω Resistor

1 * Breadboard

Several jumper wires 


Principle of operation

The principle of this experiment is very simple and is quite similar with that in the first lesson. K e y f u n c ti o n : ●for statements The for statement is used to repeat a block of statements enclosed in curly braces. An increment counter is usually used to increment and terminate the loop.The for statement is use ful for any repetitive operation,and is often used in combination with arrays to operate on collections of data/pins. There are three parts to the for loop header: for (initialization; condition; increment) { //statement(s); }

The initialization happens first and exactly once. Each time through the loop, the condition is tested; if it's true, the statement block, and the increment is executed, then the condition is tested again. When the condition becomes false, the loop ends. 

Experimental code

//File name:   Experiment 1

//Description:  flowing LED .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/06/08 


void setup()

  unsigned char ledPin;           //ledPin will be set to 1,2,3,4,5,6, 7 and 8.

  for(ledPin=1;ledPin<=8;ledPin++)//In turn set 1 ~ 8 digital pins to output mode 

  pinMode(ledPin,OUTPUT);         //Set the  ledPin pin to output mode 

}


void loop()

{   

  unsigned char ledPin;           //ledPin will be set to 1,2,3,4,5,6, 7 and 8.

  for(ledPin=1;ledPin<=8;ledPin++)//Every 200ms on in order LED1 ~ 8 

  {

    digitalWrite(ledPin,HIGH);    //led on

    delay(200);                   //Delay 200 ms

  }

  for(ledPin=1;ledPin<=8;ledPin++)//Every 200ms off in order LED1 ~ 8 

  {

    digitalWrite(ledPin,LOW);     //led off

    delay(200);                   //Delay 200 ms

  } 

}

Compile the program and upload to Arduino UNO board Now,you can see 8 LEDs light up in sequence from the red one on the right side to others on the left, and next from the left to the right.The LEDs flash like flowing water repeatedly in a circular way
7 August, 2019
0 Comment Leave Comments

Experiment description 5

In this lesson, we will program the Arduino UNO to achieve sending and receiving data through the serial port. The Unoboard receive datasent froma PC,thencontrolsanLEDaccordingtothereceiveddata,andatlastreturnsthe state of the LED to Serial Monitor in Arduino IDE. 

Hardware Required

- 1 * Arduino UNO

- 1 * USB Cable

- 1 * LED

- 1 * 220Ω Resistor

- 1 * Breadboard

- Several jumper wires 

Principle of operation

1 . Serial port.

Used for communication between the Arduino board and a computer or other devices.All Arduino boards have at least one serial port(also known as a UART or USART). It communicates on digital pins 0 (RX) and 1 (TX) as well as with the computer via USB. Thus, if you use these functions, you cannot also use pins 0 and 1 for digital input or output. You can use the Arduino environment's built-in serial monitor to communicate with an Arduino board.Click the serial monitor button in the tool bar and select the same baud rate used in the call to begin(). To use these pins to communicate with your personal computer, you will need an additional USB-to-serial adaptor, as they are not connected to the UNO's USB-to-serial adaptor. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin,and the ground of your UNO to your device's ground.(Don't connect these pins directly to an RS232 serial port;they operate at+/-12V and can damage your Arduino board.)

2 . Key function

begin() Sets the data rate in bits per second (baud) for serial data transmission. For communicating with the computer, use one of these rates: 300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, or 115200. You can, however, specify other rates - for example, to communicate over pins 0 and 1 with a component that requires a particular baud rate.

Syntax:

Serial.begin(speed)

Parameters : speed: in bits per second (baud) - long

Returns : nothing 

print()

Prints data to the seria lport as human-readable ASCII text.This command can take many forms.Numbers are printed using an ASCII character for each digit. Floats are similarly printed as ASCII digits, defaulting to two decimal places. Bytes are sent as a single character. Characters and strings are sent as is. 

For example: Serial.print(78) gives “78”

Serial.print(1.23456) gives “1.23”

Serial.print('N') gives “N” Serial.print(“Hello world.”) gives “Hello world.”

An optional second parameter specifies the base (format) to use; permitted values are BIN (binary, or base 2), OCT (octal, or base 8), DEC (decimal, or base 10), HEX (hexadecimal, or base 16). For floating point numbers, this parameter specifies the number of decimal places to use. For example:

Serial.print(78, BIN) gives “1001110”

Serial.print(78, OCT) gives “116”

Serial.print(78, DEC) gives “78”

Serial.print(78, HEX) gives “4E”

Serial.println(1.23456, 0) gives “1”

Serial.println(1.23456, 2) gives “1.23”

Serial.println(1.23456, 4) gives “1.2346”

You can pass flash-memory based strings to Serial.print() by wrapping them with F(). For example:

Serial.print(F(“Hello World”))

To send a single byte, use Serial.write().

Syntax: Serial.print(val)

Serial.print(val, format)

Parameters :

val: the value to print - any data type format: specifies the number base (for integral data types) or number of decimal places (for floating point types)

Returns  byte print() will return the number of bytes written, though reading that number is optional

println() Prints data to the serial port as human-readable ASCII text followed by a carriagereturncharacter(ASCII13,or'∖r')andanewlinecharacter(ASCII10, or '∖n'). This command takes the same forms as Serial.print().

Syntax : Serial.println(val)

Serial.println(val, format)

Parameters : val: the value to print - any data type format: specifies the number base (for integral data types) or number of decimal places (for floating point types)

Returns : byte

println() will return the number of bytes written, though reading that number is optional

read() Reads incoming serial data. read() inherits from the Stream utility class.

Syntax:

Serial.read()

Parameters:

None Returns :

the first byte of incoming serial data available(or-1 if no data is available)-int

Experiment code

//File name:   Experiment 5

//Description: If you send a character ‘1’ or ‘0’ on the  serial monitor, the status of LED will be lit or gone out.

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/06/08


int ledpin=7;           //definition digital 7 pins as pin to control the LED


void setup()

{

  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps

  pinMode(ledpin,OUTPUT);//Set digital 11 port mode, the OUTPUT for the output

}

void loop()

{

    char receiveVal;                  // Defined receive data

   

    if(Serial.available() > 0)       //Receive serial data

    {        

        receiveVal = Serial.read();  //Save the serial data received 

        

       if(receiveVal == '1')          //Receive data is 1, lit LED lights    

       { 

           digitalWrite(ledpin,HIGH); //print out the value of the LED       

           Serial.println("LED:ON"); //send data to the serial monitor

       }

       if(receiveVal == '0')          //Receive data is 0, off LED lights

       { 

           digitalWrite(ledpin,LOW);  //print out the value of the LED                

           Serial.println("LED:OFF");//send data to the serial monitor

      } 

    }

  delay(50);                          //delay 100ms

}


Compile the program and upload to Arduino UNO board Open IDE, click to open Serial Monitor, and then select the appropriate baud rate according to the program. Now, enter '1' or '0' in the textbox on the monitor, and the LED will be turned on/off.



7 August, 2019
0 Comment Leave Comments

Experimental 4

In this tutorial,we will learn how to switch On -Off LED using 5volt relay. Its simply mean when the relay sucks, the LED will light up; when the relay breaks, the LED will go out .

Hardware Required

1 x Arduino Uno

1 x USB Cable

1 x 5v Relay

1 x LED

1 x BC547 Transistor

1 x 1n4007 Diode or 1n4001 diode

1 x 680Ω Resistor or 1kΩ Resistor

1 x 220Ω Resistor

1 x Breadboard

1 x Several jumper wires 

Principle of operation

A relay is an electromagnetic operated switch. It is generally used in automatic control devices. Actually, it is an "automatic switch" which uses low current to control high current.It plays a role of automatic regulation,security protection and circuit switch. When an electric current is passed through the coil it generates a magnetic field that activates the armature, and the consequent movement of the movable contact(s)either makes or breaks(depending upon construction) a connection with a fixed contact. If the set of contacts was closed when the relay was de-energized, then the movement opens the contacts and breaks the connection, and vice versa if the contacts were open. When the current to the coil is switched off,the armature is returned by a force, approximately half as strong as the magnetic force, to its relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in industrial motor starters. Most relays are manufactured to operate quickly. In a low-voltage application this reduces noise; in a high voltage or current application it reduces arcing. When the coil is energized with direct current, a diode is often placed across the coil to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage spike dangerous to

Brief Description on BC547

BC547 is a NPN transistor hence the collector and emitter will be left open (Reverse biased) when the base pin is held at ground and will be closed (Forward biased) when a signal is provided to base pin. BC547 has a gain value of 110 to 800, this value determines the amplification capacity of the transistor. The maximum amount of current that could flow through the Collector pin is 100mA, hence we cannot connect loads that consume more than 100mA using this transistor. To bias a transistor we have to supply current to base pin, this current (IB) should be limited to 5mA.

BC547 as Amplifier

A Transistors acts as an Amplifier when operating in Active Region. It can amplify power, voltage and current at different configurations.

Some of the configurations used in amplifier circuits are

  1. Common emitter amplifier
  2. Common collector amplifier
  3. Common base amplifier

BC547 Equivalent Transistors

BC549, BC636, BC639, 2N2222 TO-922N2222 TO-18, 2N2369, 2N3055, 2N3904,2N3906, 2SC5200

Each time you press the button, the Arduino will regard you have pressed the button many times due to the jitter of the button You should deal with the jitter of buttons before using. You can eliminate the jitter through software programming. Besides, you can use a capacitor to solve the issue. Take the software method for example. First, detect whether the level of button interface is low level or high level. If it is low level, 5~10ms delay is needed. Then detect whether the level of button interface is low or high. If the signal is low, you can infer that the button is pressed once. You can also use a 0.1uF capacitor to avoid the jitter of buttons.

Brief Description and the use of Relay

Relays are most commonly used switching device in electronics. Let us learn how to use one in our circuits based on the requirement of our project.

Before we proceed with the circuit to drive the relay we have to consider two important parameter of the relay. Once is the Trigger Voltage, this is the voltage required to turn on the relay that is to change the contact from Common->NC to Common->NO. Our relay here has 5V trigger voltage, but you can also find relays of values 3V, 6V and even 12V so select one based on the available voltage in your project. The other parameter is your Load Voltage & Current, this is the amount of voltage or current that the NC,NO or Common terminal of the relay could withstand, in our case for DC it is maximum of 5V and 10A. Make sure the load you are using falls into this range. 

Experiment code

//File name:   Experiment 4

//Description: controlling of  an LED using 5v relay.

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/06/08

const int relayPin = 11; //the base of the transistor attach to pin 11


void setup()

{

  pinMode(relayPin, OUTPUT); //initialize the relayPin as an output

}


void loop()

{

  digitalWrite(relayPin, HIGH); // this energize the relay coil to turn on LED

  delay(1000); //wait for a second


  digitalWrite(relayPin, LOW); //this de-energize the relay coil to turn off LED

  delay(1000); //wait for a second

}



Compile the program and upload to Arduino Uno board Now, Now let's see what will happen: When the set of contacts are closed, the LED lights up; when they are open, the LED goes out. 


5 August, 2019
1 Comment Leave Comments

Experimental 3

In this tutorial,we will learn how to detect the state of a button,and then toggle the state of the LED based on the state of the button

Hardware Required

1 x Arduino Uno

1 x USB Cable

1 x Button

1 x LED

1 x 10kΩ Resistor

1 x 220Ω Resistor

1 x Breadboard

1 x Several jumper wires 

Principle of operation

Buttons are a common component used to control electronic devices. They are usually used as switches to connect or disconnect circuits. Although buttons come in a variety of sizes and shapes, the one used in this experiment will be a 12mm button.


Button

The button we used is a normally open type one. The two contacts of a button are in the off state under the normal conditions; only when the button is pressed they are close

Each time you press the button, the Arduino will regard you have pressed the button many times due to the jitter of the button You should deal with the jitter of buttons before using. You can eliminate the jitter through software programming. Besides, you can use a capacitor to solve the issue. Take the software method for example. First, detect whether the level of button interface is low level or high level. If it is low level, 5~10ms delay is needed. Then detect whether the level of button interface is low or high. If the signal is low, you can infer that the button is pressed once. You can also use a 0.1uF capacitor to avoid the jitter of buttons.


Experiment code

//File name:   Experiment 3

//Description: controlling an LED by a button.

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/04/01 

int ledpin=12; //definition digital 11 pins as pin to control the LED

int buttonpin=2; //Set the digital 2 to button interface

 

volatile int state = LOW; // Defined output status LED Interface

 

void setup()

{

  pinMode(ledpin,OUTPUT);//Set digital 11 port mode, the OUTPUT for the output

  pinMode(buttonpin,INPUT); //Set digital 2 port mode, the INPUT for the input

}

 

void loop()

{

  if(digitalRead(buttonpin)==LOW) //Detection button interface to low

  {  

      delay(10);  //Delay 10ms for the elimination of key leading-edge jitter

      if(digitalRead(buttonpin)==LOW)      //Confirm button is pressed

      {    

        while(digitalRead(buttonpin)==LOW);//Wait for key interfaces to high

        delay(10); //delay 10ms for the elimination of key trailing-edge jitter

        while(digitalRead(btnpin)==LOW);//Confirm button release

        state = !state; //Negate operation, each time you run the program here, state the HGIH becomes LOW, or the state becomes the LOW HGIH.

        digitalWrite(ledpin,state);     //Output control status LED, ON or OFF

      }

   }

}

Compile the program and upload to Arduino Uno board Now, you can detect the status of an external button,and then toggle the state of LED on/off relying on the state of the button detected before.

4 August, 2019
0 Comment Leave Comments

Experimental 2

In this tutorial, we will be interfacing a Active Buzzer  with Arduino uno and learn to beeps

the buzzer continuously with a delay of a 2second, using Arduino Micro-controller Board and BC547 Transistor.

In this experiment,we will program the Arduino GPIO as a high level. Then the transistor BC547 will conduct, and the buzzer will make sounds. Set the GPIO as low, the transistor BC547 will be de-energized, and the buzzer will stop beeping. 

Hardware Required

1 x Active Buzzer

1 x Arduino UNO R3 Board

1 x breadboard

1 x 680Ω resistors (1W)

1 x USB cable

1x BC547 Transistor

Several jumper wires.

In this experiment,the buzzer we used is active buzzer. Active buzzers will sound as long as they are powered. We can program to make the Arduino output alternating high and low levels to make the buzzer beep.

A slightly larger current is needed to make a buzzer beep.However,the output current of Arduino GPIO is too low, so we need a transistor to increase current.

Principle of operation

Buzzer

A buzzer or beeper is an audio signaling device. As a type of electronic buzzer with an integrated structure, which uses DC power supply, buzzers are widely used in computers,printers, photocopiers,alarms, electronic toys,automotive electronic equipments, telephones, timers and other electronic products for voice devices. Buzzers can be categorized as active and passive buzzers. Place the pins of the buzzer face up, and then you can see the two types of buzzer are different - the buzzer with a green circuit board onside is a passive one.

Transistor 
The main function of a transistor is to enlarge the voltage or current. It can also be used to control the circuit conduction or deadline. Transistors can be divided into two kinds: NPN, like the BC547 we provided; PNP, like the BC557 provided.

Experiment code

//File name:   Experiment 2

//Description:  beeps an ActiveBuzzer .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/04/01 

int ActiveBuzzerPin=3; //definition digital 3 pins as pin to control the buzzer

void setup()

{

    pinMode(ActiveBuzzerPin,OUTPUT); //Set digital 3 port mode, the OUTPUT for the output

}

void loop()

{  

    digitalWrite(ActiveBuzzerrPin,HIGH); //Set PIN 3 feet as HIGH = 5 v 

    delay(2000);                   //Set the delay time,2s 

    digitalWrite(ActiveBuzzerPin,LOW);  //Set PIN 3 feet for LOW = 0 v 

    delay(2000);                   //Set the delay time,2s

}

Compile the program and upload to Arduino UNO board Now, you can hear the buzzer beeping.
4 August, 2019
0 Comment Leave Comments

Experimental 1

In this tutorial, we will be interfacing a single LED Bulb with Arduino UNO R3 Board (Arduino UNO) and learn

to blink an LED ON and OFF with a delay of a second, using Arduino Microcontroller Board.

Hardware Required

1 x 5MM LED Bulb Red

1 x Arduino UNO R3 Board

1 x USB cable

1 x breadboard

1 x 220Ω resistors (1Watt)

2 x jumper wires

Principle of operation

In this experiment,we will program the Arduino's GPIO output high level(+5V)and low level (0V), and then make the LED which is connected to the Arduino’s GPIO flicker with a certain frequency

What is an LED ?

The LED is the abbreviation of light emitting diode. It is usually made of gallium arsenide, gallium phosphide semiconductor materials. The LED has two electrodes: a positive electrode and a negative one.

It lights up only when a forward current passes, and it can flash red, blue, green, yellow, etc. The color of the light depends on the material it is made. In general, the drive current for LED is 5-20mA.

Therefore, in reality it usually needs an extra resistor for current limitation so as to protect the LED

What is Resistor?

The main function of the resistor is to limit currents. In the circuit, the character ‘R1’ represents resistor, and the unit of resistor is ohm(Ω). 

Key function

*setup() The setup()function is called when a sketch starts.Use it to initialize variables, pin modes, start using libraries, etc. The setup function will only run once, after each power up or reset of the Arduino board.

* loop() After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely what its name suggests, and loops consecutively,allowing your program to change and respond. Use it to actively control the Arduino board.

*pinMode() Configures the specified pin to behave either as an input or an output. As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pullups.

*digitalWrite() Write a HIGH or a LOW value to a digital pin. If the pin has been configured as an OUTPUT with pin Mode(),its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V boards) for HIGH, 0V (ground) for LOW.

If the pin is configured as an INPUT,digitalWrite() will enable(HIGH) or disable (LOW) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor.

*delay() Pauses the program for the amount of time (in miliseconds) specified as parameter. (There are 2000 milliseconds in a second.)


Experiment code

//File name:   Experiment 1

//Description:  blink an LED .

//Website: www.okuelectronics.com

//E-mail: support@okuelectronics.com

//Author: Okudzeto osei prince

//Date: 2019/04/01 

int LEDPin=2; //definition digital 2 pins as pin to control the LED Bulb(Note 'int' is variable type).

void setup()

{

    pinMode(LEDPin,OUTPUT);    //Set the digital 2 port mode, OUTPUT: Output mode

}

void loop()

{  

    digitalWrite(LEDPin,HIGH); //HIGH is set to about 5V pin2

    delay(1000);               //Set the delay time, 1000 = 1S

    digitalWrite(LEDPin,LOW);  //LOW is set to about 5V pin2

    delay(1000);               //Set the delay time, 1000 = 1S

Compile the program and upload to Arduino UNO board Now you can see the LED blinking.