Friday, July 8, 2016

Serial Monitoring


Serial Monitoring is done in Arduino (software). So, before you can check whether your sensor is working fine or not, you need to install the arduino software. If you don't have arduino, you can download it from here.

Once you install arduino in your computer, you need to connect the sensor pins to the arduino hardware and the hardware to the computer. The sensor pins give an analog input to the arduino, i.e the output from the sensors are variable as they sense differently in different conditions. For example, if they sense the white color, they may send a small voltage, while on the other hand, if they sense something darker, they may send a comparatively greater voltage depending on the configuration of your sensor.

So, make sure that you connect the sensor pins to the analog pins of arduino (A0 - A5). Since, there are five sensor pins in your sensor board, you can connect them to respective pins A0 - A4. Also, make sure that you give a 5V power supply to your sensor board either by an external battery or through the arduino itself. After you connect all the pins, your sensor board is ready for serial monitoring.

Now, what you need to do is, write a program in arduino to monitor your sensors. If you are familiar with the programming language C, then you will not have difficulties coding in arduino. Both are pretty much the same with slight differences. Here is a screenshot of the code that is going to help you for serial monitoring. I have written down some comments too, so that you understand the code precisely.


Setting Up the modes for the analog pin and Baud Rate for Serial Monitoring






Taking input from the sensors and printing it in the Serial Monitoring Window

If the images are not clear, then you can download them from here.
Image1
Image2 

To summon up the program, basically what we are doing is, we set the analog pins A0 - A4 in INPUT Modes, take the input from the sensors and print them in the serial monitor window of arduino. To open the serial monitor window, press  "Ctrl + Shift + M".


Now, you can see the values given by your respective sensors in the serial monitor window. This is the time when the POT (potentiometer) connected to the sensor board comes to use.
Make sure you have a white paper below all your IR sensors and watch the values in the serial monitor window. Now, try to make all the values to a similar range by rotating the top of each POT in either direction. For example, if the 1st sensor shows 308, then try to adjust the values of all other sensors at around (290 - 320) by rotating the POT for each.

Once you adjust a similar range of values for all the sensors, replace the white paper underneath with a black one and then observe the values again. If the values differ from the previous values by a fine range (about a difference of 400-500), then it confirms that your sensor board is working perfectly fine.
Also, make sure that after you replace the white paper with a black one, the values given by all five sensors are within a range just like the previous time.

NOTE: Here, the range of the values given by the sensors is between 0 to 1023. This is because we are using a microcontroller that is a 10 bit microcontroller. So, the total number of values possible is 2^10 (i.e. 1024).



No comments:

Post a Comment

Featured Post

Line Following Robot With Manual Control

Line Following Robot With Manual Control: Line Following Robot Components Required: Arduino UNO A Chasis for your BOT ( Yo...