Sensor Fundamentals

AVR SeriesHuman-like Robots

Dear readers, please note that this is the old website of maxEmbedded. The articles are now no longer supported, updated and maintained. Please visit the new website here and search for this post. Alternatively, you can remove .wordpress from the address bar to reach the new location.

Example: If the website address is, then removing .wordpress from it will become

We apologize for the inconvenience. We just want to give you a better viewing and learning experience! Thanks!

Humans (or in general any living organism) has to have some senses to become totally autonomous. Humans have five senses – vision, smell, taste, hearing and touch. If so, then what do robots have?

Human-like RobotsLet me ask you a simple question. What does a robot needs to become totally autonomous? By totally autonomous, I mean that the robot should work on its own without any human interference. Most of you would agree with me that it needs intelligence. This intelligence is imparted by us (humans). But is it enough?  Well, of course the robot will work with that, but it will be totally isolated from the outside world. It won’t be interactive and cannot take decisions valid in the real world. In order for it to interact with the real world, we need to implant sensors!

In simple words, a sensor is any device capable of sensing physical parameters (like temperature, pressure, proximity, etc) and then convert into electrical signals so that it can be used for processing. So, what do robots have? Camera, piezoelectric sensors, acoustic sensors, accelerometer, etc.

Sensor Fundamentals

Now let’s move on to some of the fundamentals of sensors. Starting with the basic question, what can we measure using sensors?Practically anything! Light, motion, temperature, magnetic fields, gravity, humidity, vibration, pressure, electrical fields, sound, and other physical aspects of the external environment can be measured using them. Of course there are different sensors for each purpose like IR sensors, proximity sensors, temperature sensors, tilt sensors, accelerometers, ultrasonic sensors, RADAR, SONAR, etc.

Different Types of Sensors Available

Different Types of Sensors Available

Every sensor in this world has three terminals:

  • Vcc – to power up the sensor
  • GND – to provide a fixed negative reference
  • Output – analog output of the sensor (in some sensors, there may be more than one output terminals)

The following block diagram demonstrates it.

Sensor - Block Diagram

Sensor – Block Diagram

The sensor senses the physical parameters and gives a corresponding output. In most cases the output is analog. Some of the most common sensors used in the field of robotics and embedded systems are as follows:

  • IR Sensor

    IR Sensor

    IR Sensor– This is the most fundamental type of sensor available in the market. The basic concept is simple. There is an emitter which emits infrared (IR) rays. These IR rays are detected by a detector. This concept is used to make proximity sensor (to check if something obstructs the path or not, etc), contrast sensors (used to detect contrast difference between black and white, like in line follower robots), etc. The circuit diagram of a basic IR sensor is given below. So even you can make one by yourself.

    Basic Design of IR Sensor

    Basic Design of IR Sensor

    You can also put an op-amp (comparator) in the output terminal in order to amplify the signal and also to convert the analog sensor output to a digital one. We will discuss analog to digital conversion (using AVR) later. For more details on IR sensor design and construction, visit this page.

  • LM35


    LM35 Temperature SensorLM35 is a precision centigrade temperature sensor. It has three terminals – Vcc, Ground and Output – as shown in the adjoining diagram. It has a sensitivity of 10mV/°C. This means that for every degree rise in temperature, the output voltage increases by 10mV. In general, it gives a voltage of 0V at 0°C. Hence, say for an output of 450mV, the temperature is 45°C.

  • Apart from LM35, there are many other temperature sensors like thermistors, thermocouples, etc which are widely used.
  • MMA7260 Tri-Axis Accelerometer

    MMA7260 Tri-Axis Accelerometer

    Accelerometer – An accelerometer is a device which can measure acceleration in any direction (X, Y, Z). MMA7260 is one such tri-axis accelerometer. Even this has three major terminals – Vcc, ground and output (it has three outputs, one each for X, Y and Z). This is a very cool stuff. You can program graphical LCDs using this, you can implement this in humanoids (if you plan to make one) to measure the rate of fall, etc. Here is a short tutorial on using analog accelerometers.

  • Camera– To give your robot the power of vision, you can put cameras on them.
    Axis IP Camera

    Axis IP Camera

    The image processing is done using software like MATLAB, OpenCV, LabVIEW, etc and then the data is transferred to the MCU using serial communication. Even this is a cool stuff! In fact I am presently working on this and hope to bring you some exciting concepts regarding Digital Image Processing!

Well, these were just a few of the sensors. There are many other types of sensors used. Of course, the discussion of all of them is outside the scope of this post. So now, you have the fundamentals of the sensors. In the next post, we will discuss how to convert the analog output of sensors to digital signals using AVR.

29 responses to “Sensor Fundamentals

  1. Pingback: The ADC of the AVR « maxEmbedded·

  2. Oh my goodness! an amazing article dude. Thank you However I am experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting identical rss problem? Anyone who knows kindly respond. Thnkx

    • thanks a lot for your response! 🙂
      well, dunno why it isn’t working.. try once again.. or else you can subscribe via email too! 🙂 or add it to ur google reader account..

    • The IR gives an analog output. The microcontroller is a digital device. Thus, you need to convert the analog signal into digital one. This can be done in two ways -:
      1. Use the internal ADC of the microcontroller
      2. Use external ADC (like using a comparator circuit)

  3. hey Rex Ryan……i’m also experiencing the same problem with rss feed……
    Anyway this blog is awesome……..

  4. Pingback: Sensor Interfacing and ADC | roboVITics·

  5. Pingback: Basic Parts of a Robot « maxEmbedded·

  6. Hi this s ragu
    currently im doing project on the topic bldc controller. for that i need to generate PWM signal for 6 switches and also i want to vary duty cycle through variable pot using ADC converter. i am posting my code pls help its not working

    Code can be found here.

    pls help me

  7. Pingback: ADC and Sensor Interfacing | roboVITics·

    • First of all, I want to know how are you using IR sensor i.e. using op-amp as a comparator or without using op-amp. If you are using op-amp to amplify and convert analog signal to single bit digital signal, then you can directly just connect the output of your sensor to any of GPIO pins of ATMEGA 16 and use DDRx register to assign that pin as input pin.
      If your are not using any op-amp and directly taking the output from your photodiode, then you need to connect it ADC pins of ATMEGA 16. To learn about ADC, visit this.

  8. i am making linefollower robot with atmega16.But i am facing problem in giving input and taking output from ir sensors.can u pls send the code for taking signals from sensors using inbuilt ADC in atmega16

    • First, assign your input ports using DDRx. Now, if you want to give your port input. You can use following syntax for taking inputs from two IR sensors.

      the above mentioned syntax can be used and modified as per requirements of line follower.

  9. your site has been resourceful on many areas thanks.I have been trying to write code for hc-sro4 ultrasonicsensor(4 pin) but i cant get anywhere using the timer concepts of the using atmega8
    and there is lots of stuff about it(sensor) on the other sites which is more confusing, please help on this area.

    • Hello Issac,

      There are two types of ultrasonic sensors available – analog and digital. HC-SRO4 is a digital one. Usually analog ones are easy to use. Did you read its datasheet? It is clearly explained how to provide the trigger and get the echo. Simply provide 10us pulses to Trigger pin and monitor the Echo pin. You need to measure the time difference between two consecutive pulses of the Echo pin, then put in the formula to get the range. Here is a video as well. Though the video is for Arduino, you can at least get the concept.

  10. Pingback: Using an Analog Accelerometer | maxEmbedded·

  11. Pingback: How to build an IR Sensor | maxEmbedded·

We'd love to hear from you!

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s