Uncategorized

4. ARDUINO LIBRARIES

4.1       Introduction to Arduino Libraries Arduino IDE comes with plenty libraries that you can call and use in your sketches. Although there are some 3rd party libraries that you must download and install. These libraries are usually specific to some components and sensors that you want to connect to your Arduino. It is therefore important for you to know how to install such libraries. 4.2       Installing the Arduino Libraries There are three main ways of installing Arduino libraries; 4.2.1        Downloading the library from the Library Manager You can directly download and install the library from the library manager by following Sketch>Include Library>Manage Libraries on the menu bar. Once you click Manage Libraries on the dropdown list, the Library Manager window shown in figure below will pop up. You can then search for and install the library from the Library Manager. Fig. 4. 1 Library Manager window 4.2.2        Adding .ZIP library The second way of installing library onto the Arduino IDE is by adding a genuine zipped Arduino library. You first need to download the zipped library from your favorite browser and mark the directory of download. You can then install the library by following Sketch>Include Library>Add .ZIP Library on the menu bar. Once you click Add .ZIP Library on the dropdown list, the window (dialogue box) shown in figure below will pop up. You can then find the zipped library you have just downloaded and then click open on the dialogue box to install the library. Fig. 4. 2 Open file dialogue box 4.2.3        Manually Copying and Pasting the into the libraries folder. One can also install the library by manually copying and pasting it in the libraries folder of the Arduino. If you are having Windows Operating System, then the Arduino libraries folder is found in C:UsersusernameDocumentsArduinolibraries. You should make sure that the library is first unzipped before copying and pasting it in the Arduino libraries folder. Also be sure to restart your Arduino IDE for the manually copied and pasted library to work.

4. ARDUINO LIBRARIES Read More »

3. ARDUINO INTERNAL DEVELOPMENT ENVIRONMENT

3.1  Introduction to Arduino Internal Development Environment In order to program the Arduino (make it do what you want it to), you upload the code from the Arduino Integrated Development Environment (IDE). The IDE enables you to write a computer program, which is a set of step-by step instructions that you then upload to the Arduino. Your Arduino will carry out those instructions and interact with the world outside. These Arduino programs are known as sketches. In this section, we are going to download and install the Arduino IDE. We will then use the “Blink.ino” example code in the IDE to blink the Arduino Built-in LED. Consider following the below steps; 3.2            Download the Arduino IDE Download the latest version of the Arduino IDE from the Arduino website. Once the download has finished, double click to install. The installation process is self-guiding. You only need to follow the steps.   Agree to the license terms by clicking the agree button.  The next window is about the optional features you would like to install along with the Arduino software. If you prefer the program to automatically create the desktop shortcut be sure to select the option. It is good to ensure that all the options are selected. Click next The next window allows you to choose the installation directory. I recommend that you leave the default directory and just click install. The installation process will start and it will take some minutes to finish. Once the installation is complete you will be prompted to close the setup. Just click the close button. Launch the Arduino IDE program from the desktop shortcut. The following window will appear. This is the Arduino IDE where you write your programs to feed into the Arduino. The IDE is very simple and easy to use. 3.3            Connect the Arduino Firstly, get your Arduino board and lay it on the table. Take the USB cable and plug the B plug end into the USB jack on the Arduino. Next, connect the other end of the USB cable into the USB socket on your PC. You will see the power LED (usually green) on the board light up to show that you have powered the board. You will now have to select the appropriate Arduino board from the Tools > Board > Arduino Uno. You will be provided by the list of the Arduino boards. Be sure to select the appropriate board. For my case I will select the Uno board because it’s the one I am using. Select the communication port for your Arduino from the Tools > Port > COM21(Arduino Uno). Note: Your COM port number may differ from mine. We are now going to blink the inbuilt LED on the Arduino board. This LED is connected to the digital 13 of the Arduino board. You can access the example code by going to File > Examples > Basics>Blink. To upload the code you will click the upload button on the Arduino IDE. This upload button is represented by the right facing arrow below the menu bar. Clicking this button will upload the code into the Arduino board. If there is no error in your coding and connection, you will see the done uploading message on the lower left corner of the Arduino IDE as shown below.  The on-board LED labelled L will blink in an interval of 1 seconds. Congratulation!!! You have just successfully uploaded your first Arduino program.

3. ARDUINO INTERNAL DEVELOPMENT ENVIRONMENT Read More »

2. ARDUINO AND ARDUINO BOARDS

2.1       What is an Arduino An Arduino is an Open Source small computer that you can program to process its input and output pins. It was originally designed for students without a background in electronics and programming. Through the use of hardware and software, one can use the Arduino to interact with the environment. An example is to have a temperature sensor connected to Arduino so as to measure the ambient temperature. You can as well have both the sensor and an actuator connected to the Arduino. Where by the sensor measures the state of the environment while the actuator is used to perform the control function based on the measurements obtained from the sensor. Since the Arduino board is cheap and readily available in almost all parts of the world, it has revolutionized the world in a number of ways. Firstly, it has become the best learning tool for those who wants to learn software and hardware development at the same time. Secondly, Arduino has gain a lot of popularity amongst the Do It Yourself (DIY) hobbyist and you can see the wonders they have done with it all over the internet. Lastly, there are infinite number of automatic vending machines out there whose backbone is the Arduino board. As a result, a number of companies and individuals have benefitted much in gainful employment and income earning opportunities. The Arduino board is made of a microcontroller which forms the heart of the board.  It also has a crystal oscillator which basically acts as a clock that sends time pulses to the microcontroller to enable it to operate at the correct speed. The board also has digital and analog Input and Output pins to enable one to connect the microcontroller pins to other components such as LEDs, sensors, shields and modules. The Arduino Integrated Development Environment (IDE) is used to write a computer program that you can then upload to the Arduino. Once the code is uploaded to the Arduino, it will carry out the instructions in the code and enables the Arduino interact with the outside world. 2.2      Types of Arduino Boards There are many kinds of Arduino boards but the most common ones are; Uno Mega Leonardo Nano Due Fig. 2. 1 Types of Arduino boards The Arduino Uno board offers the best option for the beginners in the Arduino world. It consists of 14-digital pins and 6-analog pins. The digital pins can be used as both the input/output (I/O) pins to the Arduino while the analog pins as input pins. Fig. 2. 2 Architecture of the Arduino Uno Board You now know what an Arduino is and what it can do. In the next topic we will get started with the Arduino. This will involve downloading and setting up the Arduino IDE for uploading the codes (Arduino Sketches). We will then use the Arduino in a number of projects.

2. ARDUINO AND ARDUINO BOARDS Read More »

1. MEASUREMENT, INSTRUMENTATION AND AUTOMATIC CONTROL SYSTEMS

1.1       Introduction to measurement and instrumentation 1.1.1        Measurement Measurement refers to the process of comparing unknown quantity with the standard one. It provides us with the means for describing chemical and physical parameters of materials quantitatively. Therefore, when one mentions the word measurement, what comes into the mind is the weight, length, distance, time, height, temperature, color of a material. The standard used for measurement should be accurate and internationally accepted. It also important that the experimental procedure adopted while performing the measurement should be scientifically provable. The International System of Units (SI) defined seven base units of measurement known as the SI base units. The SI base units are; Table 1. 1 The seven Base Units Quantity SI unit Symbol Length Metre m Time Second s Mass Kilogram kg Electric Current Ampere A Thermodynamic Temperature Kelvin K Luminous Intensity Candela cd Amount of Substance Mole mole The base units are the building blocks of the system. All the other units are derived from the base units and are known as SI derived units and the quantity as the SI derived quantity. There are unlimited number of SI derived quantities and units.  An example of the SI derived quantity is the velocity (with the derived unit as m/s) which is derived from dividing length by time. 1.1.2        Instrumentation Instrumentation refers to the technology of using instruments to measure and control physical and chemical properties of a system. It is important for monitoring and maintaining the operation of a system within the design expectations so as to achieve good quality, safety and efficiency of the process. It helps achieve automatic control of process there by reducing the dependency on human labor. Measurement and instrumentation are very essential to system control. Be it a spaceship, air conditioner, aircraft, etc. they all rely on measurement and instrumentation in order to make a decision. We are going to construct a number of instruments for measurement and use them to achieve automatic control of systems. 1.2       Functional Elements of a Measurement System (Instrument) The functional elements of a measurement system are; 1.2.1        Sensing element This is the primary sensing object on the instrument. An element that is sensitive to the variable being measured. It is the first part of the instrument to sense or detect the measurement and then produces an output that is proportional to the measurement. 1.2.2        Transducer (Variable Conversion) element The output signal of the sensing element can be of any form. Sometimes, this output is not suited to the measurement system. The transducer element converts the signal from one physical form to another while maintaining the information content of the original signal. 1.2.3        Variable manipulation element Variable manipulation element modifies the signal presented to it while preserving the original nature of the signal. It does this by amplification, attenuation and filtration so that the desired output is produced. 1.2.4        Signal conditioning element Signal conditioning involves the removal of the unwanted noise and distortion from the signal through filtration. 1.2.5        Data transmission element In a situation whereby the elements of an instrument are physically separated, it becomes necessary to transmit data from an element to another. The data transmission element transmits data from one location to another while preserving the information content of the data. 1.2.6        Data presentation element This is the element that provides record or indication of the output on a measurement instrument. If the data is to be monitored, visual display devices are necessary. In case the data is to be recorded, recorders like SD cards, magnetic tapes, and high speed camera are necessary. 1.3       Input-Output configuration of a measurement system A measurement instrument performs an operation on measured input (i) to provide an output (o) called measurement. The performance of the instrument can be expressed in terms of the operational transfer function (G). The relationship between the input and output is characterized by the transfer function such that; There are three categories of inputs in a measurement system; 1.3.1        Desired input This is the quantity that the instrument is intended to measure during the measurement. 1.3.2        Interfering input This is the quantity that the instrument is not intended to measure but the instrument is unintentionally sensitive to the quantity. 1.3.3        Modifying input This quantity takes into account the desired and interfering inputs to modify the input-output relation. Generalization of the Measurement System The measurement system can be generalized into input stage, intermediate stage and output stage according to the figure below; Fig. 1. 1 Generalization of the measurement system 1.4       Performance characteristics of a measurement system The following terms are used to describe the performance characteristics of an instrument; 1.4.1        Accuracy Taking into account that no instrument gives the exact value of what is being measured, there is always uncertainties in the measured values. Accuracy refers to how close the measured value is to the true value. 1.4.2        Calibration These are the procedures undertaken to for checking and adjusting instrument’s scale so that the readings conform to an accepted standard. 1.4.3        Repeatability This describes how close the outputs are when the same input under the same conditions are applied repeatedly. 1.4.4        Range and Span Range is the region between the limits within which a measuring instrument is designed to operate, while the span represents the algebraic difference between those upper and lower limits. 1.4.5        Precision This is the ability of the measuring instrument to give a certain group of readings with a certain accuracy. 1.4.6        Sensitivity This is expressed as a ratio of the output signal to the input signal. 1.4.7        Speed of response This is the rapidity within which an instrument responds to the quantity being measured. 1.5       Introduction to Control Systems Before we consider a control system lets first consider the following two terms; 1.5.1        System A system is an assemblage of devices connected to form an organized structure in order to perform a specific task. 1.5.2        Control The ability to influence, direct, command or regulate the behavior of a system or course of events. It’s a

1. MEASUREMENT, INSTRUMENTATION AND AUTOMATIC CONTROL SYSTEMS Read More »

Introduction to C++ Programming Language

What is C++ It is not a surprise that developers write computer programs to solve specific problems. These programs may range from a single line to thousand and thousand lines of codes. In order to do this, the developer must first figure out the problem to solve and the appropriate computer language to use. There are a number of programming languages and the choice will depend on the developer himself as well as the advantages of the language over the others. One of the mostly taught and used languages is the C++ programming language. The C++ is a high level programming language which is an extension of the C language. It is widely taught in a number of schools and institutions worldwide. This is because learning C++ comes with many benefits. The benefits of learning C++ Before getting started with C++ programming, it is important to first know and understand the benefits associated with learning C++; Firstly, C++ is a cross-platform language. This means that C++ is independent of a particular operating system. It can be implemented in multiple operating systems. It is important to develop a cross-platform software so that it can run in a variety of devices. C++ runs on a number of platforms such as Windows, Mac, and UNIX operating systems. C++ is a high level programming language. A high level programming language is one which is closer to human language than the machine language. It is an easy to learn language. Since C++ is a high level language, it is easy to learn. Lastly, C++ is object oriented programming (OOP) language. Rather than procedural programming, it is important to adopt the object oriented approach while writing your programs.  Object oriented programming involves the creation of objects. Each object is characterized by its behavior and attributes. The four main principles of the object orientated programming are; Encapsulation Data abstraction,  Inheritance, and  Polymorphism.       We will learn more about the OOP in the progressive chapters. Since we have now learnt what the C++ programming language is and its benefits, we are now ready to get started with C++. Consider the next topic, Getting started with C++. Take an Exam

Introduction to C++ Programming Language Read More »

Arduino DHT22 Temperature Humidity sensor

In this tutorial, we will learn how to connect Arduino with DHT22 sensor. 1). What you will need  DHT Arduino library  Adafruit_sensor.h library  Jumper wires 16×2 LCD compatible with Hitachi HD44780 driver Arduino board  Breadboard  10K ohm potentiometer  220 ohm resistor  Arduino USB cable  Temperature humidity sensor (DHTxx series or AMxxxx series)  2).  Connect it up        VSS pin of the LCD to ground        VCC pin of the LCD to 5V        RS pin of the LCD to digital pin 7 of the Arduino        R/W pin of the LCD to ground        E pin of the LCD to  digital pin 6 of the Arduino        D4 pin of the LCD to  digital pin 5 of the Arduino        D5 pin of the LCD to  digital pin 4 of the Arduino        D6 pin of the LCD to  digital pin 3 of the Arduino        D7 pin of the LCD to  digital pin 2 of the Arduino For  220 ohm resistor         one end to A pin of the LCD and the other end to 5V     For  10k ohm potentiometer         Slider pin of the potentiometer to LCD VO pin of the LCD          A and B pins of the potentiometer to +5V and ground respectively     Arduino with DHT22        GND pin of the sensor to  ground        Data pin of the sensor to  digital pin 8 of the Arduino        VCC pin of the sensor to  5V       Note: NC (Not Connected) pin should not be connected to anything 3).  Type in the code Open up your Arduino IDE and type in the code below.  The sketch uses the dht sensor to measure the environmental temperature and relative humidity . The results are displayed on the LCD screen.  4).  Power up and upload the sketch (code) Power up the Arduino from your pc using usb cable. Lastly, upload the sketch onto your board.  For reference, see the video below.

Arduino DHT22 Temperature Humidity sensor Read More »

Liquid Crystal Display Arduino tutorial

In this tutorial I will demonstrate the use a 1602 Liquid Crystal Display (LCD) with Arduino. This will involve four simple steps. You can find the pins configuration of the 1602 LCD by following the tutorial on the Introduction to 1602 Liquid Crystal Display. 1). What you will need  Male to male jumper wires  1602 LCD compatible with Hitachi HD44780 driver  Arduino board R3 Breadboard  10K ohm potentiometer  220 ohm resistor  Arduino USB cable  2).  Connecting the Liquid Crystal Display with Arduino        VSS pin of the LCD to ground        VCC pin of the LCD to 5V        RS pin of the LCD to digital pin 7 of the Arduino        R/W pin of the LCD to ground        E pin of the LCD to  digital pin 6 of the Arduino        D4 pin of the LCD to  digital pin 5 of the Arduino        D5 pin of the LCD to  digital pin 4 of the Arduino        D6 pin of the LCD to  digital pin 3 of the Arduino        D7 pin of the LCD to  digital pin 2 of the Arduino     For  220 ohm resistor         one end to A pin of the LCD and the other end to 5V     For  10k ohm potentiometer         Slider pin of the potentiometer to LCD VO pin of the LCD          A and B pins of the potentiometer to +5V and ground respectively 3).  Type in the code Open up your Arduino IDE and type in the code below. The sketch uses a nested for loop (loop within a loop) to calculate the product of two real numbers x and y and then displays the result z which is also a real number.  //Include the LCD library #include <LiquidCrystal.h> //Initialize the LCD arduino pins LiquidCrystal lcd(7,6,5,4,3,2); void setup() { //LCD number of columns and rows: lcd.begin(16, 2); } void loop() { int x, y, z; //where we will have x*y = z for(x=1; x<=9; x++) //Outer loop { lcd.clear(); //Clear the contents on the screen lcd.setCursor(3,0); // set the cursor to column 3, line 0 lcd.print(“TABLE NINE”); for(y=1; y<=9; y++) //Inner loop { z=x*y; lcd.setCursor(3,1); // column 3, line 1 lcd.print(x); lcd.setCursor(5,1); // column 5, line 1 lcd.print(“x”); lcd.setCursor(7,1); // column 7, line 1 lcd.print(y); lcd.setCursor(9,1); // column 9, line 1 lcd.print(“=”); lcd.setCursor(11,1); // column 11, line 1 lcd.print(z); delay(1000); // delay for 1 second } } } 4).  Power up and upload the sketch (code) Power up your Arduino from your pc using usb cable and then upload the sketch onto your board. Refer to the below video.

Liquid Crystal Display Arduino tutorial Read More »

Introduction to 1602 Liquid Crystal Display (16×2 LCD)

A 1602 liquid crystal display (LCD) module consists of 16 columns and two rows. This means that the LCD can display 16 characters per line (16 Characters x 2 Line). The LCD has found a wide range of applications because of its cheap price and the ease to program. The LCD can display the alphabet and number characters making it an alphanumerical display module. Each character is built on a 5×8 pixels dots. It is also possible to display special and custom generated characters on this type of display. See the datasheet.   Pinouts and Pin description of a 1602 liquid crystal display module The VSS and the VDD pins are used to power the LCD and are connected to the ground and +5 volts respectively. VO pin is for adjusting the contrast of the LCD and is normally connected to a potentiometer (variable resistor). RS pin is the Register Select pin. This will select data register when high, and command register when low. Read/Write (R/W) pin is used to toggle the LCD between the read from and write to the register operations. When set low, R/W pin will write to the register. While on the other hand, when set high, it will read from the register. This pin is normally grounded for the data writing operations to the LCD as in our example below. Enable (E) pin is the data read/write operations enable signal. Pins D0 – D7 are for data transfer. D0 – D3 is restricted to 8-bit data. For our case, we will be using pins D4 – D7 for both the 4 bits and 8 bits data transfer. BLA and BLK are for powering the LCD backlight with +5volts and ground respectively. The 1602 LCD can be connected directly to the micro-controller boards such as the Arduino. The other alternative is to use the I2C module. The module will help minimize the number of pins to be taken from the micro-controller while interfacing it with the LCD (LCD I2C).  

Introduction to 1602 Liquid Crystal Display (16×2 LCD) Read More »

Getting Started with the Arduino (IDE)

In the previous section (Introduction to Arduino) we learnt about Arduino. In this section we are going to download and install the Arduino IDE. We will then use the example code in the IDE to blink the Arduino Built-in LED. Consider following the below steps;   Download the Arduino IDE Download the latest version of the Arduino IDE from the Arduino website. Once the download has finished, double click to install. The installation process is self-guiding. You only need to follow the steps.   Agree to the license terms by clicking the agree button.  The next window is about the optional features you would like to install along with the Arduino software. If you prefer the program to automatically create the desktop shortcut be sure to select the option. It is good to ensure that all the options are selected. Click next The next window allows you to choose the installation directory. I recommend that you leave the default directory and just click install. The installation process will start and it will take some minutes to finish. Once the installation is complete you will be prompted to close the setup. Just click the close button. Launch the Arduino IDE program from the desktop shortcut. The following window will appear. This is the Arduino IDE where you write your programs to feed into the Arduino. The IDE is very simple and easy to use. Connect the Arduino Firstly, get your Arduino board and lay it on the table. Take the USB cable and plug the B plug end into the USB jack on the Arduino. Next, connect the other end of the USB cable into the USB socket on your PC. You will see the power LED (usually green) on the board light up to show that you have powered the board. You will now have to select the appropriate Arduino board from the Tools > Board > Arduino Uno. You will be provided by the list of the Arduino boards. Be sure to select the appropriate board. For my case I will select the Uno board because it’s the one I am using. Select the communication port for your Arduino from the Tools > Port > COM21(Arduino Uno). We are now going to blink the inbuilt LED on the Arduino board. This LED is connected to the digital 13 of the Arduino board. You can access the example code by going to File > Examples > Basics>Blink. To upload the code you will click the upload button on the Arduino IDE. This upload button is represented by the right facing arrow below the menu bar. Clicking this button will upload the code into the Arduino board. If there is no error in your coding and connection, you will see the done uploading message on the lower left corner of the Arduino IDE as shown below.  The on-board LED labelled L will blink in an interval of 1 seconds. Congratulation!!! You have just successfully uploaded your first Arduino program.

Getting Started with the Arduino (IDE) Read More »

Shopping Cart
Scroll to Top