How to use 18B20 in Proteus ISIS

Hello friends, hope you all are fine and having fun with your lives. In today's post we are gonna have a look at How to use Temperature Sensor 18B20 in Proteus ISIS. I will use Arduino board as a microcontroller and will connect the temperature sensor with it and then will display the code on LCD. I have already posted the same tutorial in which I have done Interfacing of Temperature Sensor 18B20 with Arduino but in that project I have used the real components and designed the hardware. But today, I will just show you the simulation so that you could test the simulation first and then design it in hardware.

Temperature Sensor 18B20 is the most commonly used temperature sensor. Its a one wire sensor means it sends data through a single wire and we can connect multiple sensors with a single wire, that's why its quite efficient and easy to use as well. I have also posted a tutorial on How to Interface LM35 sensor with Arduino in Proteus ISIS which is another temperature sensor so give it a try as well and let me know which one you think is better. Anyways let's get started with temperature sensor 18B20 in Proteus ISIS.

How to use 18B20 in Proteus ISIS ???

  • First of all, get these components from Proteus components list as shown in below figure:
  • Now design the circuit as shown in below figure:
  • As you can see in above simulation, we have used Arduino UNO board along with LCD and 18B20 temperature sensor.
  • 18B20 in Proteus can't detect the real temperature but we can change the temperature by pressing + and - buttons.
  • So, now we have interfaced the temperature sensor and the LCD with Arduino. Next we are gonna design the code for Arduino and will upload it in Arduino baord.
Note:
  • Now download these three libraries, one is "one wire" library which is the protocol for 18B20 temperature sensor, next is the Dallas Temperature sensor library which is the actua library for temperature sensor 18B20 and uses one wire library. Third library is the Crystal LCD library which is used for displaying character on LCD.
  • So, download all these three libraries by clicking on below buttons and then paste them in your libraries folder of Arduino software.

Download One Wire LibraryDownload Dallas Temperature LibraryDownlaod Liquid Crystal Library

  • Now after adding these libraries, open your Arduino software and paste the below code into it.
    #include <OneWire.h>
    #include <DallasTemperature.h>
    #include <LiquidCrystal.h>

    #define ONE_WIRE_BUS 6
    OneWire oneWire(ONE_WIRE_BUS);
    DallasTemperature sensors(&oneWire);

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
 
    void setup(void)
    {
    Serial.begin(9600);
    Serial.println("Welcome to TEP !!!");
    Serial.println("www.TheEngineeringProjects.com");
    Serial.println();
    sensors.begin();

    lcd.begin(20, 4);
    lcd.setCursor(5,0);
    lcd.print("Welcome to:");
    lcd.setCursor(1,2);
    lcd.print("www.TheEngineering");
    lcd.setCursor(4,3);
    lcd.print("Projects.com");
    delay(5000);
    }

    void loop(void)
    {
    sensors.requestTemperatures();
    Serial.print("Temperature : ");
    Serial.println(sensors.getTempCByIndex(0));
    //lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Temperature: ");
    lcd.print(sensors.getTempCByIndex(0));
    lcd.print("C");
    delay(1000);
    }
  • Now get your hex file from Arduino and upload it to your Proteus Arduino board and hit the RUN button.
  • If everything goes fine then you will something like this at the start:
  • After a delay of around 5 sec you will start receiving the Temperature sensor 18B20 values on your LCD as shown in below figure:
  • Now you can see the value shown in the temperature sensor is the same as in LCD.
  • So, now by clicking the + and - buttons on temperature sensor, you can increase and decrease the value of temperature and same will be changed in LCD.
That's how you can do simulation of Temperature sensor 18B20 in Proteus ISIS. Its quite simple and easy to use. That's all for today, hope you get some knowledge out of it.

Upload Latest Firmware in Pixy Camera

[vc_row][vc_column][vc_column_text]

Hello friends, hope you are fine and having fun with your lives. Till now we have seen two tutorials on Pixy Camera module, in the first tutorial we have seen How to Get started with Pixy Camera and after that we have seen How to Install Pixy Camera software which is named as PixyMon. So, now I hope that you have installed the Pixy camera software and have the Pixy Camera module in hand along with USB to Mini USB cable. Because in this tutorial we are gonna plug our Pixy Camera module with moduter and will upload the latest firmware in our Pixy Camera Module, which isn't much difficult and would be a piece of cake if you followed all the instructions carefully.

Pixy Camera comes with some old firmware which is uploaded in it at the time of its manufacturing. But with the passage of tme, the firmware keeps on upgrading and hence in order to make the Pixy Camera module compatible with new software, we have to upgrade the Pixy Camera firmware as well, which we are gonna do in this post.We haven't yet connected our Pixy Camera module with computer so when we plug it with our computer for the first time, it will first install the driver for the usb of pixy Camera board and then we will be able to upload our latest firmware in it. So, before uploading firmware in Pixy Camera first let's have a look at How to install the driver for Pixy Camera module.

How to Install Driver for Pixy Camera ???

  • Plug your USB cable in Pixy Camera from USB mini side and plug the USB side into your computer.
  • Now when you plug your Pixy camera for the first time, a small pop up will open up in the task bar as shown in below figure:
  • And you don't need to do anything and it will get installed automatically. I have tested it on Windows 8 and it works like magic, no problem at all.
  • Now once you installed the driver for Pixy Camera, unplug your pixy Camera USB and now we will see how to upload latest firmware in Pixy Camera.

Upload Latest Firmware in Pixy Camera

  • So, now I hope you have unplugged your Pixy Camera USB from computer.
  • Now download the latest firmware of Pixy Camera by clicking the below button.

  • At the time of writing this post, the latest firmware available was 2.0.17 but you can download the latest firmware by clicking here.
  • Now I hope you have downloaded the latest firmware for pixy Camera, so now open your PixyMon software and first time it will look something as shown in below figure:
  • Now press the white button on your Pixy Camera and plug the USB in your computer while keep pressing the button.
  • Once the USB plugged in and USB got detected, then release the button and you will get something like this in your PixyMon.
  • As shown in above figure, our Pixy Camera got detected and because we pressed the button so that's why it went in programming state.
  • Soon after this a pop up will open up as shown in below figure:
  • Now Browse to your downloaded firmware, which in my case is pixy_firmware-2.0.17-general.hex , so I selected this one and press Open.
  • It will automatically install the firmware and will restart the Pixy Camera and you will get something like this in your PixyMon.
  • That's all, now you will start getting your video from Pixy Camera and you can see in the output pane that it installed the firmware first and then for reset and now ready to use.
Now we have uploaded the Latest Firmware in our Pixy Camera and have also plugged it with our computer and got it working with PixyMon. In the next tutorial, we will see How to train our Pixy Camera using this PixyMon. I am quite tired now so I don't think I am gonna post the next tutorial today, hopefully will post it tomorrow. So, till then take care :)) [/vc_column_text][vc_empty_space height="30px"][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]<< How to Install Pixy Camera Software [/vc_column_text][/vc_column][vc_column width="1/2"][vc_column_text]

How to Train Pixy Camera with PixyMon >>

[/vc_column_text][/vc_column][/vc_row]

How to Install Pixy Camera Software - PixyMon

[vc_row][vc_column][vc_column_text]

In the previous tutorial, we have seen how to Get Started with Pixy Camera, which was quite a basic tutorial and we have covered just the basic cables required to set up pixy camera. Now along with cables we are also gonna need software for training our Pixy Camera. So in this tutorial we are gonna see how to install Pixy Camera Software which is named as PixyMon. As I explained earlier in previous post that first of all, we need to connect our Pixy Camera with Computer or laptop and then using its software PixyMon we need to train our Pixy Camera so that it can recognize objects present in front of it.

PixyMon is quite a simple software and quite easy to use. In this post, we are not gonna check How to use PixyMon software (which is the topic for net tutorial) but we are gonna see How to install pixy Camera software successfully without any errors. So now I hope that you have bought the Pixy Camera and have also bought the USB to mini USB cable because we are gonna need to it in order to connect our Pixy Camera with computer and make it work with PixyMon software.

I could have covered the whole tutorial in a single post but then its gonna be real messy because we need to cover quite a lot of things that's why I thought to divide it in parts so that we cover each and every thing in detail and even a begineer can easily follow these tutorials and could work on PixyMon Camera Module. After checking the installation of PixyMon software, in the next tutorial we will have a look at How to upgrade the drivers for Pixy Camera Module. So now let's get started with installation of PixyMon.

Note:

  • Don't connect your Pixy camera with computer, first we will install the PixyMon software which will also install the driver for USB cable and then we will plug our Pixy Camera with computer.

How to Install Pixy Camera Software - PixyMon

  • As I mentioned above, PixyMon is a software which is used to train our Pixy Camera module using Computer.
  • So, first of all download the PixyMon software by clicking on the below button:

  • At the time of writing this post, the latest version of PixyMon released is 2.0.9 for Windows so either download the software by clicking above button or visit http://cmucam.org/projects/cmucam5/files (Official site for PixyMon) to download latest version of PixyMon.
  • Now after downloading the PixyMon, double click it to open and the first window will show up is shown in below figure:
  • Now when this window pop up, click on the Next button.
  • When you click the Next Button, the below window will open up.
  • Now here Browse to your folder where you wanna install the PixyMon software and then click the Next button and you will get the below screen:
  • Now here simply click the Next button again unless you wanna change the folder for the shortcut, which is not necessary.
  • Now finally when you hit the Next button, it will show you all the configurations you set and will ask you to install the software as shown in below figure:
  • Now hit the Install button and your software will start to install as shown in below figure:
  • Now during installation, a new window will pop up as shown in below figure:
  • Simply press OK button, this pop up is asking for the driver to install for the USB cable which we will plug in after installation of this software.
  • Now that's the last window for installation of PixyMon software. Simple click Finish and you are done with the installation of Pixy Camera software.
Now we are done with installation of Pixy Camera software, in the next tutorial we are gonna have a look at How to install latest firmware for Pixy Camera. So stay tuned. :)[/vc_column_text][vc_empty_space height="30px"][/vc_column][/vc_row][vc_row][vc_column width="1/2"][vc_column_text]<< Getting Started with Pixy Camera[/vc_column_text][/vc_column][vc_column width="1/2"][vc_column_text]

Upgrade Pixy camera Firmware >>

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][vc_column_text][/vc_column_text][/vc_column][/vc_row]

Getting Started with Pixy Camera

Hello friends, hope you all are fine and having fun with your lives. Today's post is about getting started with pixy camera. Now, the first thing comes in mind is what is Pixy Camera so let's first have a little introduction about Pixy Camera on which I recently worked. Pixy Camera is a small camera board which uses NXP microcontroller. Its a very powerful board and can get easily interfaced with simple Arduino UNO board. So, now we can do image processing even on Arduino UNO. Image Processing needs a powerful board that's why we can't interface simple webcam with Arduino UNO or mega etc. Before using pixy camera, when I need to do on board image processing I always used either Arduino YUN, Raspberry Pi or Arduino USB host shield but still it was quite tough to do the image processing even on such powerful boards like Arduino YUN. But now with Pixy Camera module, one can quite easily do the image processing even on Arduino UNO.

Now question arises what this module does ? Actually this Pixy module has a NXP microcontroller on it which does all the image processing and is controlled by a computer. (We are gonna cover this in coming tutorials) Once you set its parameters like color detection or object detection etc then you simply unplug it from computer and plug it with Arduino or any other PIC Microcontroller. Now whenever that object comes in front of Pixy Camera it will automatically recognize it and will send the command to your microcontroller and will also send the parameters like X, Y coordinates or size etc of the object and what you need to do is to apply your algorithm on Arduino i.e. what you gonna do if the object is infront of the camera. Sounds complex, don't worry we are gonna follow everything in detail in coming tutorials. So, now we are gonna have a look at how to get started with Pixy Camera.

Getting Started with Pixy Camera

  • So, when I ordered for my Pixy Camera, I got the box within 10 days.
  • As I received the box I opened it and I got two items from it, one is the Pixy Camera board itself and second is the Serial to SPI cable which is used to connect Pixy Camera with Arduino or PIC Microcontroller.
  • The Pixy Camera is shown in below figure:
  • The Serial to SPI cable which is received has 9 pins on one end which is inserted in Pixy board while six pins on the other end which is inserted in Arduino Microcontroller.
  • This cable is also shown in below figure:
  • The black side of this cable is for microcontroller while the white side is for Pixy Camera board itself.
  • Next cable you are gonna need is the USB to mini USB cable, which is not with the package so you need to get it on your own.
  • I got mine as well and is shown in below figure:
  • This cable is used to connect your Pixy Camera board with computer.
  • Using this cable, we train our Pixy camera and let it know about colors and objects.
  • We actually set signature using Pixy Camera Software, which I am gonna cover in my next tutorial and using this software we make pixy do incredible things.
Now we have all the tools to get started with Pixy Camera so now in the next tutorial, we will have a look at How to install Pixy Camera software in Windows. Click the below button to move to next tutorial. If you having questions please ask in comments below. [vc_empty_space height="30px"]

How to Install Pixy Camera Software >>

Control Servo Motor with Arduino in Proteus

Hello friends, hope you all are fine and having fun with your lives. Today's post is about the Controlling of Servo Motor with Arduino in Proteus ISIS. Servo Motor is a common motor used in engineering projects for precise circular motion. We can move the servo motor at any desired angle, which is not possible in the case of other motors i.e. Stepper or DC.

For example, suppose I want to move an antenna at a precise angle of 47.5 degrees then if I use DC Motor, I have to use an encoder. So, in such cases instead of using a DC motor, I will prefer Servo Motor.

I have already posted Angle Control of Servo Motor using 555 Timer in which I have controlled servo motor using 555 timer and another tutorial about Controlling of Servo Motor using PIC Microcontroller in which I have controlled it with PIC16F877a. And today we are going to Control Servo Motor with Arduino and will design the simulation in Proteus ISIS.

First of all, we will have a look at simple control of servo motor with Arduino in Proteus ISIS and then we will check the control of the servo motor with Arduino using buttons in which we will move the servo motor to precise angles using buttons. So, let's get started with it. :)

Where To Buy?
No.ComponentsDistributorLink To Buy
1Servo MotorAmazonBuy Now
2Arduino UnoAmazonBuy Now

Simple Control of Servo Motor with Arduino in Proteus

  • First of all, open your Proteus ISIS software and design the below simple circuit.
  • You should also have a look at these Proteus Libraries of Components.
  • Servo Motor has three pins:
    1. First Pin is Vcc.
    2. Second Pin is Control Pin.
    3. Third Pin is GND.
  • The center pin is the controlling pin and goes to any digital pin of Arduino. I have connected the control pin to pin # 4 of Arduino.

Arduino Code for Servo Motor Control

  • The next thing we need to do is to design the code for Arduino. So, open your Arduino software and copy paste the below code in it.
#include <Servo.h> 
 
Servo myservo;  
int pos = 0;    

void setup() 
{ 
  myservo.attach(4);  
}
 
void loop() 
{ 
  for(pos = 0; pos <= 180; pos += 1) 
  {
    myservo.write(pos);              
    delay(15);                      
  } 
  for(pos = 180; pos>=0; pos-=1)     
  {                                
    myservo.write(pos);             
    delay(15);                      
  } 
}
  • Now compile this code and get your hex file.
  • It's the same code as given in the Servo folder of Examples in Arduino software.
  • Upload your hex file to your Proteus Arduino board.
Note:

Proteus Simulation Results

  • Now, run your simulation and you will see that your Servo motor will start moving from 90 degrees to -90 degrees and then back to 90 degrees and will keep on going like this, as shown in the below figures:
  • Now when you start it, first of all, it will show Position A in the above figure then will move anticlockwise and pass the position B and finally will stop at Position C and then it will move clockwise and comes back to Position A after passing Position B.
  • In this way, it will keep on moving between Position A and C.
  • Till now we have seen a simple control of Servo Motor with Arduino in Proteus ISIS, now let's have a look at a bit complex control of servo motor with Arduino.

Control Servo Motor with Arduino using Push Buttons

  • In the previous section, we have seen a simple Control of Servo Motor with Arduino in which we simply moved Servo motor from 90 degrees to -90 degrees and vice versa.
  • Now I am going to control Servo motor using five push buttons and each push button will move the Servo motor to a precise angle.
  • So, first of all, design a small design as shown in the below figure:
  • I have added five buttons with Arduino and now with these five buttons, I will move the Servo motor to 90, 45, 0, -45 and -90 degrees. So, each button has its precise angle and it will move the motor to that angle only.

Arduino Code

  • So, now the next thing is the code, copy paste the below code in your Arduino software and get the hex file:
#include <Servo.h> 
 
Servo myservo;   

int degree90 = 8;
int degree45 = 9;
int degree0 = 10;
int degree_45 = 11;
int degree_90 = 12;

void setup() 
{ 
  myservo.attach(4);  
  pinMode(degree90, INPUT_PULLUP);
  pinMode(degree45, INPUT_PULLUP);
  pinMode(degree0, INPUT_PULLUP);
  pinMode(degree_45, INPUT_PULLUP);
  pinMode(degree_90, INPUT_PULLUP);
}
 
void loop() 
{ 
  if(digitalRead(degree90) == LOW)
  {
    myservo.write(180);
  }
  
  if(digitalRead(degree45) == LOW)
  {
    myservo.write(117);
  }
  
  if(digitalRead(degree0) == LOW)
  {
    myservo.write(93);
  }

  if(digitalRead(degree_45) == LOW)
  {
    myservo.write(68);
  }
  
  if(digitalRead(degree_90) == LOW)
  {
    myservo.write(3);
  }
}
  • Upload this hex file to your Arduino board in Proteus and run the simulation.

Proteus Simulation Results

  • Now press these buttons from top to bottom and you will get the below results:
  • The above figure is quite self-explanatory but still, I explain a little.
  • In the first figure, I pressed the first button and the motor moved to -90 degrees.
  • In the second figure, I pressed the second button and the motor moved to -45 degrees.
  • In the third figure, I pressed the third button and the motor moved to 0 degrees.
  • In the fourth figure, I pressed the fourth button and the motor moved to 45 degrees.
  • In the fifth figure, I pressed the fifth button and the motor moved to 90 degrees.
  • In the sixth figure, all buttons are unpressed and the motor remained at the last position.

It was quite simple and hope I explained it properly. If you still have any questions then ask in the comments and I will try to resolve them. That's all for today, will see you guys in the next tutorial. Take care !!! :)

Color Detection in Images using MATLAB

Hello friends, hope you all are fine and having fun with your lives. In today's tutorial, we are gonna see Color Detection in Images using MATLAB. In the previous tutorial, I have posted about How to Detect Circles in Images using MATLAB in which we have detected objects based on their geometrical figure means either they are circle or not but today we are gonna distinguish objects based on their color i.e. whether they are red colored or green colored etc. Its a quite simple tutorial and comes in the basic category. We will first detect the color and then will create a boundary around that object and will also show its XY coordinates as well.

Image processing is an important tool of MATLAB. We can quite easily do the image processing in it using Image Processing toolbox so you need to make sure that your MATLAB must have Image processing toolbox before running this code. You should also have a look at these MATLAB Image Processing Projects. So, let's start with the project.

Color Detection in Images using MATLAB

  • In order to do the Color Detection in Images using MATLAB, first thing we are gonna need is the image itself. :P
  • So, I designed an image in paint which has different shapes in different colors as shown in below figure:
  • As you can see in the above figure, there are different shapes in different colors so now we are gonna detect these objects on the basis of their color.
  • Now use the below code and add it in your MATLAB m file, if you are new to m File then have a look at How to Create m File in MATLAB.
  • If you wanna protect your code in m File then you should read How to Protect code in m File.
    data = imread('TEP.jpg');
    diff_im = imsubtract(data(:,:,2), rgb2gray(data));
    %Use a median filter to filter out noise
    diff_im = medfilt2(diff_im, [3 3]);
    diff_im = im2bw(diff_im,0.18);
    
    diff_im = bwareaopen(diff_im,300);
    
    bw = bwlabel(diff_im, 8);
    
    stats = regionprops(bw, 'BoundingBox', 'Centroid');
    
    % Display the image
    imshow(data)
    
    hold on
 
    for object = 1:length(stats)
        bb = stats(object).BoundingBox;
        bc = stats(object).Centroid;
        rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
        plot(bc(1),bc(2), '-m+')
        a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
        set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'black');
    end
    
    hold of
  • Now, run your m file and if everything goes fine then you will get an image as shown in below figure:
  • You can see in the above figure, we have only detected the shapes with green color.
  • The + sign indicates the center of each detected shape.
  • X and Y are the x,y coordinates of the center point of each shape which are shown in black for each detected shape.
  • Now, let's detect the red color in above figure, so in order to do so what I need to do is to simply change the third value in imsubtract function from 2 to 1.
  • The complete code for red color detection in MATLAB is shown below:
    data = imread('TEP.jpg');
    diff_im = imsubtract(data(:,:,1), rgb2gray(data));
    %Use a median filter to filter out noise
    diff_im = medfilt2(diff_im, [3 3]);
    diff_im = im2bw(diff_im,0.18);
    
    diff_im = bwareaopen(diff_im,300);
    
    bw = bwlabel(diff_im, 8);
    
    stats = regionprops(bw, 'BoundingBox', 'Centroid');
    
    % Display the image
    imshow(data)
    
    hold on
 
    for object = 1:length(stats)
        bb = stats(object).BoundingBox;
        bc = stats(object).Centroid;
        rectangle('Position',bb,'EdgeColor','r','LineWidth',2)
        plot(bc(1),bc(2), '-m+')
        a=text(bc(1)+15,bc(2), strcat('X: ', num2str(round(bc(1))), ' Y: ', num2str(round(bc(2)))));
        set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 12, 'Color', 'black');
    end
    
    hold off
  • Now, when you run this code in MATLAB, you will get the output as shown in below figure:
  • Now instead of detecting the green shapes, it has now detected the red shapes in MATLAB.
  • And have also shown their x,y coordinates in black color.
  • Now, finally let's detect the blue color, in order to do, you now just need to change the third parameter to 3 and it will detect the blue color as shown in below figure:
  • That's all for today, and I think its quite an easy one as I mentioned earlier this one is quite basic tutorials. Thanks for reading and I hope it will help you in some ways. :)

Detect Circles in Images Using MATLAB

Hello friends, hope you all are fine and having fun with your lives. In today's post we are gonna see How to detect Circles in Images using MATLAB. It's quite a simple and basic tutorial but quite helpful as today I was working on a project in which I need to do so but all the codes available online were for detection and tracking of circles in live images. So, I thought to share this one on our site. I have also posted another tutorial Color Detection in Images using MATLAB, so I think its better if you check that one as well.

We all know about MATLAB, which is a great tool for image processing and quite easy as it has a strong Help section. I haven't posted much tutorials on MATLAB in my blog so from now on I am gonna post tutorial on MATLAB as I get many requests about it. If you have any requests then use our Contact form and send them to us and I will try my best to postrelated tutorials. I personally prefer OpenCV over MATLAB, when it comes to image processing but in OpenCV there's not much flexibility as in MATLAB. Anyways, let's start our tutorial which is How to Detect Circles in Images using MATLAB.

Detect Circles in Images Using MATLAB

  • First of all, you are gonna need an Image, in which you are gonna find circles so I used this image of a bike.
  • As we can see there are two circles in the above image, which are two tyres, so we are gonna detect them now.
  • So, copy the below code and paste it in your MATLAB m file.
ImagePath='TEP.jpg'; %Give Path of your file here
Img=imread(ImagePath);

Img=im2bw(Img(:,:,3));  
Rmin=70;
Rmax=100;  
[centersDark, radiiDark] = imfindcircles(Img, [Rmin Rmax], ...
                                        'ObjectPolarity','bright','sensitivity',0.90)
imagesc(Img);
hold on
viscircles(centersDark, radiiDark,'LineStyle','--');
hold off
  • Now, when you run this code you will get something as shown in below figure:
  • As you can see in the above figure, both the circles are now detected and are marked with red and white line.
  • The command, I have used for detecting these circles is imfindcircles , where Rmin and Rmax are the minimum and maximum radius of the circles.
  • It will detect only those circles which will lie in this range and other circles will be ignored.
  • Moreover, the last parameter is for setting the sensitivity of circle detection, which I have given is 0.90.
  • It will also give the center of these circles along with their radii in the command window as shown in below figure:
  • As, we have detected two circles so the command window is showing the X, Y coordinates of both these circles along with their radii.
  • Now test it and also change the minimum and maximum ranges and you will see you are gonna detect more circles.
It was quite easy but if you have problem in it then ask in comments and I will try my best to solve them. That's all for today, will meet in next tutorial. Till then take care !!! :)

How to Reset Arduino Programmatically

Hello friends, hope you all are fine and having fun with your lives. Today's post is about How to Reset Arduino Programmatically. Sounds a bit weird, yes it is :) but literally in some cases, this technique is the only choice you have. It recently happened to me in one of my projects, that's why I know How important it is. Before going into details, let's first have a look at the resetting feature of Arduino.

If you have worked on any Arduino board, then you must have noticed the RESET pin in Arduino and you may wonder what's the use of this pin. So, today this pin is gonna get useful. Moreover, you have also noticed that when you upload the code to your Arduino board then the Arduino resets, another way of resetting Arduino is by opening the Serial Terminal in Arduino software, while connecting your Arduino board to your computer. As you open the Serial Terminal, the Arduino automatically gets reset. The third way of resetting Arduino is by pressing the push button. When you press and release the push button, Arduino gets reset. You should also have a look at How to get Hex File from Arduino.

So till now we have seen three ways of resetting Arduino but you have noticed that all of these methods are manual, you have to manually push the button or to open the Serial Terminal or to upload the code. Now in some projects, we have to reset Arduino Programmatically, like we don't do anything and it just reset itself automatically. Now how can we do that, that's the topic of today's tutorial. So, I am gonna share two methods today using which we are gonna reset Arduino programmatically. So, let's start with them.

Where To Buy?
No.ComponentsDistributorLink To Buy
1Jumper WiresAmazonBuy Now
2Arduino UnoAmazonBuy Now

Reset Arduino Programmatically using RESET Pin

  • In the first method, we are going to reset Arduino Programmatically using the RESET Pin available on the Arduino board.
Note:
  • If you haven't bought your Arduino UNO yet, then you can buy it from this reliable source:
  • So, first of all, connect Arduino Reset Pin with any of the digital pins as I have connected it with Pin#4 shown in the below figure:
  • Now upload the below code to your Arduino board:
 
int Reset = 4;

void setup() {  
  digitalWrite(Reset, HIGH);
  delay(200); 
  pinMode(Reset, OUTPUT);     
  Serial.begin(9600);
  Serial.println("How to Reset Arduino Programmatically");
  Serial.println("www.TheEngineeringProjects.com");
  delay(200);
}
void loop() 
{
  Serial.println("A");
  delay(1000);               
  Serial.println("B");
  delay(1000);               
  Serial.println("Now we are Resetting Arduino Programmatically");
  Serial.println();
  delay(1000);
  digitalWrite(Reset, LOW);
  Serial.println("Arduino will never reach there.");

}

  • Once you have uploaded the code then and open your Arduino Serial Monitor and you will get something as shown in the below figure:
  • As you can see in the above figure, our Arduino is not displaying the line "Arduino will never reach there" and got reset and then display from start. So that's how it's going to work.
  • Now let's have a look at the second method of How to Reset Arduino Programmatically.

Reset Arduino Programmatically using reset Function

  • In this method, we are not going to use any hardware pin, instead, we will do everything in programming.
  • So, if you don't know much about Arduino Programming then you should have a look at Getting Started with Arduino Programming.
  • Arduino has a built-in function named as resetFunc() which we need to declare at address 0 and when we execute this function Arduino gets reset automatically.
  • So, no need of doing anything in hardware and simply upload the below code to your Arduino board.
void(* resetFunc) (void) = 0;
 
void setup() {     
  Serial.begin(9600);
  Serial.println("How to Reset Arduino Programmatically");
  Serial.println("www.TheEngineeringProjects.com");
  delay(200);
}

void loop() 
{
  Serial.println("A");
  delay(1000);               
  Serial.println("B");
  delay(1000);               
  Serial.println("Now we are Resetting Arduino Programmatically");
  Serial.println();
  delay(1000);
  resetFunc();
  Serial.println("Arrduino will never reach there.");
 
}
  • Now open your Arduino Serial Terminal and you will get the same output as we get in the first method and shown below:
  • In the code you have seen that we defined the function resetFunc() and then where we call that function, our Arduino gets reset at that point.
It was quite a simple tutorial, but if you have any problems then ask in the comments and I will try to resolve them. So that's all for today and will meet in the next tutorial. Till then take care !!! :)

How to Upload Bootloader in Atmega328

Hello friends,hope you are fine and enjoying your lives. In today's tutorial, we will know How to Upload Bootloader in Atmega328 using Arduino UNO, which is quite simple and easy and a basic level tutorial. We all know that, Arduino UNO uses Atmega328 as a microcontroller and have you ever thought of using ATmega328 alone instead of using complete Arduino UNO. If you haven't thought yet then think now :) Yes we can use Atmega328 alone instead of using it as a whole with Arduino board. But that's not the topic of today's tutorial and I am gonna cover it soon that How can we use Atmega328 alone.

So now the questions arises that what we are gonna do with the rest of the Arduino board? As we have taken the Atmega328 out of it now there's no use of rest of the board. That's not quite right, we can buy another Atmega328 and can use it in this Arduino board. Now when you insert the new ATmega328 microcontroller in your Arduino UNO board then you will see that its not working? :( But no need to get sad because when it comes to technology then there's solution for everything. :)

Actually Arduino uses a bootloader installed on its Atmega328. It's kind of a driver for Atmega328 microcontroller, which makes it compatible with Arduino software. Normally in order to write code for Atmega328 we use AVR compiler but here because of this bootloader, we can quite easily upload the code into it simply from Arduino software. So, when you bought a new ATmega328 microcontroller then there's a need to upload bootloader in Atmega328. After installing the bootloader in Atmega328, now its ready to be plugged in Arduino UNO board and to be programmed. You should also have a look at How to get Hex File from Arduino. So, today we are gonna see How to upload Bootloader in ATmega328, let's start it.

How to Upload Bootloader in Atmega328 ???

  • There are many ways to upload bootloader in ATmega328 and I am gonna share the easiest of them, which is using two Arduino UNO boards.
  • So, now I suppose that you have two Arduino UNO boards and some jumper wires with you.
Note:
  • If you haven't bought your Arduino UNO yet, then you can buy it from this reliable source:

  • One of the Arduino board will be used as a programmer and it will upload the boatloader into second Arduino, while the second Arduino will be having the new ATmega328 microcontroller in which you wanna upload bootloader.
  • So, first of all, what you need to do is to connect these two Arduino UNO boards as shown in the below figure:
  • Now, in the above figure, Arduino B is acting as a programmer while Arduino A has the new ATmega328 Microcontroller in which we are gonna upload the bootloader.
  • Now connect Arduino B with your computer via USB cable and both the Arduino boards will turn ON as we have connected their 5V and GND pins.
  • Now open your Arduino software, and click on File menu and then Examples.
  • In Examples, open ArduinoISP as shown in below figure:
  • Now upload this ArduinoISP example in Arduino B board in first figure, which is acting as a programmer.
  • Now Arduino B board is ready to upload the bootloader in Arduino A board.
  • Now select the Arduino A board from Tools>Boards but I am not gonna do that as in our case we are using Arduino UNO for both programmer and the one getting programmed.
  • Now click on Tools and then Programmer and select Arduino as ISP from the options as shown in below figure:
  • Now we have done all the settings and finally we are ready to Upload Bootloader in ATmega328, so now click on Tools and then click on Burn Bootloader as shown in below figure:
  • When you click on this Burn Bootloader, TX / RX leds on both the Arduino UNO boards are gonna blibk for around 30 seconds and when they are done then you will see a message on your Arduino software that Bootloader uploaded, which means you have successfully uploaded the bootloader in your ATmega328 microcontroller and now you can upload the code into it.
Note:
  • After uploading the bootloader, go to Tools and the Programmer and change it back to AVRISP, otherwise you won't be able to upload the code in your Arduino UNO.
  • You should also download this Arduino Library for Proteus, it will enable you to simulate your Arduino in Proteus software.
That's all for today. you should also have a look at these Arduino Projects for Beginners. I think today's tutorial was not that difficult and if you have little knowledge of Arduino then you can quite easily do it, but if still having problems then ask in comments and I will solve them.

Arduino UNO PCB Design for Proteus ARES

Hello friends, hope you all are fine and having fun with your lives. Today's post, as the name suggests, is about Arduino UNO PCB Design in Proteus ARES. I have already posted Arduino Library for Proteus on my blog using which one can quite easily run Arduino simulation in Proteus.but what if you wanna do the Arduino UNO PCB design in Proteus, then you are lucky that you are reading this post. :)

In one of my projects, I have to design the PCB for Arduino in Proteus so I thought to also post it here so that others can download it as well. Normally PCB design is not required for Arduino and I usually get Atmega328 out of Arduino and use it separately but sometimes, depending on the requirements of your project, you may also need to place Arduino itself on the PCB so in such cases Arduino UNO PCB Design is required. Using this design you can place the Arduino on the PCB in upside down direction and then can take pins out and can use them as you want them to use. You should also have a look at How to do PCB Designing in Proteus ARES.

Let me give you a little introduction about Proteus ARES as I haven't posted much tutorials on it. When you install Proteus software in your computer then you get two exe files one is named as Proteus ISIS while the other one is named as Proteus ARES. If you need to test some electronic circuit i.e. need to design the simulation then you use Proteus ISIS and when you need to design the PCB design then its done in Proteus ARES. As here we are talking about the Arduino UNO PCB design so that's why we are using Proteus ARES. Here's the list of Top 10 PCB Design software. So, let's get started with it.

Arduino UNO PCB Design for Proteus ARES

  • First of all, download this Arduino UNO PCB design, which I have designed in Proteus ARES.
Download Proteus ARES Design
  • Once downloaded, then open the file and unrar it on your desktop.
  • Now double click the file to open it, make sure you already installed the Proteus software.
  • When you open it, it will look something as shown in below figure:
  • Now select the whole PCB design, right click it and select Make package as shown in below figure:
  • When you click on Make Package, a new pop up window will open up, as shown in below figure:
  • Now in the New Package Name, you can give any name to it, as I have given Arduino Shield to it and can select any Package Category.
  • After selecting these options, hit the OK button and this Arduino UNO PCB design will save in your Proteus ARES library as the name you gave it. Like mine is saved as Arduino shield.
  • Now whenever you wanna use it, you simply need to search for it and it will come up.
  • You can also attach it to your Arduino package in Proteus ISIS so that you simple design the circuit in Proteus ISIS and then design the PCB in Proteus ARES.
That's all for today, hope you got some knowledge out of it. It was quite easy but having any problems, ask in comments and I will help you out. Will see you guys in next tutorial. Till then take care :)
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir