Hello everyone. In the last post, Atmega32 explained his I/O operations and how to address its ports and pins. In this post, I will be discussing the interfacing of a simple IR sensor (digital output) and a DC motor to Atmega32. But before that I want to tell you that before trying to implement this one, make sure you have blinked a few LEDs and LED patterns so that you are quite familiar with mu-c coding in C. So, the problem statement at hand is:
Design a microcontroller based circuit that enables a DC motor to rotate for 5 seconds whenever an obstacle is detected by an IR sensor. Also, during the motion of the DC motor, an LED should glow and switch off as soon as the DC motor shaft stops rotation.
Simple enough? Let us start with the basics.
Requirements:
1) An IR sensor – already discussed in an earlier post
2) A DC motor driver circuit – already discussed in an earlier post
3) An LED and a resistor
4) A microcontroller – let us assume we are using Atmega32
Flow chart:
Circuit schematic:
The circuit schematic has been drawn using EAGLE.
Choice of I/O pins:
We have chosen:
1) PB0 as the sensor input pins
2) PB1 and PB2 as the input pins to the motor driver circuit
3) PB3 as the LED driving pin
Alternate problem statements:
Done with this much?
Now try to tweak the problem statement by changing:
1) The duration of the motor rotation
2) The direction of motor rotation
3) The on-off behaviour of the LED (switching off when obstacle detected and vice versa)
4) The range of your IR sensor by changing the potentiometer resistance
5) The I/O pins involved
Note:
1) The number of pins required for this circuit is only 4 whereas the available number of I/O pins is 32. You can go for a smaller controller like any one of the AVR Attiny series. The code won’t change. But the project settings in your development IDE will.
2) This circuit or a modified form is a basic component of almost any autonomous robot. Eg: Obstacle avoider, line-follower, micromouse etc.
3) The IR sensor output is a function of the colour of the obstacle. Try it out yourself J
Later posts will also cover some more helpful microcontroller projects. Cheers!
i was looking for an article, precisely like yours..very useful mate.
ReplyDeleteVery useful artical bro.....Keep posting articles like this ....Thnx
ReplyDeleteGood work bro. Keep it up.
ReplyDeleteI had one doubt in my mind. ATmega32 has inbuilt Comparator (in PORT A) right ? You could have made use of it instead of using Comparator externally.
Please don't mistake me if i am wrong. I am new to these stuff.
source code ? kothay pabo ?
ReplyDelete