4×3 Matrix Keypad Interface – AVR Tutorial

Many application requires large number of keys connected to a computing system. Example includes a PC keyboard, Cell Phone keypad and Calculators. If we connect a single key to MCU, we just connect it directly to i/o line. But we cannot connect, say 10 or 100 keys directly MCUs i/o. Because :- It will eat up precious i/o line. MCU to Keypad interface will contain lots of wires. Buy Matrix Keypad We want to avoid all these troubles so we use some clever technique. The technique is called multiplexed matrix keypad. In this technique keys are connected in a matrix (row/column) style as shown below. Matrix Keypad Basic Connection The rows R0 to R3 are connected to Input lines of Microcontroller. The i/o pins where they are connected are made Input. This is done by setting the proper DDR Register in AVR and TRIS Register in PIC. The column C0 to C3 are also connected to MCUs i/o line. These are kept at High Impedance State (AKA input), in high z state (z= impedance) state these pins are neither HIGH or LOW they are in TRISTATE. And in their PORT value we set them all as low, so as soon as we change their DDR bit to 1 they become output with value LOW. One by One we make each […]

Interfacing Ultrasonic Rangefinder with AVR MCUs – AVR Tutorial

Obstacle detecting sensors are one of the most basic type of sensors that electronic hobbyists use. There are several methods to make cheap obstacle sensors. These simple sensors are made using a IR Rx/Tx pair or Normal LED and LDR pair(this design is most basic and is heavily affected by environment lighting conditions). These sensor may be useful for simple requirement but they have following drawbacks :- Can’t say anything about the real distance of obstacle. Give different result for different coloured obstacles. Need calibration (like setting up a variable resistor). To solve these problems we have IR Range Finder Module (like one made by Sharp) but they have small range. Sharp GP2D12 Distance Measurement Sensor has a maximum range of 80cm Sharp GP2D120 Distance Measurement Sensor has a maximum range of 30cm only. To solve all these problem we can use an Ultrasonic Range Finder Module. An Ultrasonic Range Finder Module uses ultrasonic waves (inaudible to humans) to measure distance. These module consist of an Ultrasonic Transmitter (Tx) that emits the ultrasonic wave, the waves after striking any obstacle bounces back and reach the Ultrasonic Receiver (Rx). By measuring the time it take for the whole process to complete and using simple arithmetic we can measure the distance to the obstacle. The Ultrasonic Range Finder Modules has a wide […]

Interfacing RFID Reader with AVR MCUs – AVR Tutorial

Hello Friends!, RFID is a great technology, has may uses and become very cheap and easy to implement these days. Very interesting and useful project can be made by using RFID technology. In our tutorial series on RFID we will get introduced to this magical technology and practically create RFID based solutions. In RFID or Radio Frequency Identification their is a tag (or label) which has a unique ID stored on it. We can read this ID by using a RFID reader. Not much fun yet? Well the features which makes magical are :- The RFID tag does not need to make any electrical contact with reader (Wow!) The RFID Tag is an active device which has a chip and antenna but does NOT need any power and are low cost!(Some tags need battery) RFID tags are very small, don’t need battery so can be put in cards (looks like a credit/ATM cards) or key chains. By reading the features offered by RDIF technologies you may be wondering that the application would be much sophisticated or costly. But the good news is that we have done enough research to find the best RFID solution and they are available from our online shop. And with the help of our beginner friendly tutorials you can easily get it to work in no […]

Interfacing Graphical LCD with AVR MCU – Part III

Hello Friends, Welcome Back. This is the continuation of our tutorial series on Graphical LCD Programming. Till now we have made the hardware for testing and setup avr studio project for graphical development. Now as our hardware and software is ready, its time to get our hands dirty by digging deep into ProGFX graphical programming. Introduction The graphical LCD is made up of a grid of pixels. Common resolution is 128×64. That means that their are 64 horizontal lines and each line has 128 pixels. These displays are monochrome that means each pixel can either be ON or OFF. ON pixels looks dark while OFF pixels are nearly invisible. The glcd has a graphic RAM where each bit in ram corresponds to one pixel on screen. You write to the graphic RAM to modify its contents and the screen will change accordingly. The LCD module offers just that much functionality. You can’t do much with that. Pixel Matrix of Graphical LCD You need a graphic library that takes high level commands like Graphic primitives like line,circles, rectangle etc Text Drawing Image/Icon drawing. Double buffering. and changes the graphic memory accordingly. These operation requires some advance algorithms (at least from beginners point of view!). So the graphic library will help you generate complex graphical output very easily. Pixel Addressing The horizontal […]

Interfacing Graphical LCD with AVR MCU – Part II

This tutorial deals with downloading and installing ProGFX graphic engine. ProGFX is a free and easy to use embedded graphic library that can control several display modules and can run on AVR, PIC and ARM MCUs. In this tutorial we will make a ProGFX graphical application with Atmel AVR ATmega32 MCU using AVR Studio and WinAVR (C Compiler). So lets begin. Downloading ProGFX engine. Please download the ProGFX engine from the following link. Download ProGFX v1.0 Installing ProGFX Engine. You need WinZIP to extract the files to your hard disk. Please extract it to root of any drive like "C:". Following Folders will be created. C:\progfx\include C:\progfx\lib Folders Created after extracting the ProGFX package Note that core of the engine is contained in two folders named "include" and "lib" but there may be some others folders too, like "Help" depending on your version of ProGFX engine. Creating a Graphical Project using AVR Studio. The basic tools required for developing with AVRs are Atmel Studio (Integrated development environment with integrated C compiler) eXtreme Burner AVR (to transfer program files to chip) These tools must be installed and set up correctly as described in the following tutorial. Creating "Hello World" project with Atmel AVR. Start AVR Studio and you will be presented with the following screen. Atmel Studio 6 Startup Screen The […]

Interfacing KS0108 based 128×64 Graphical LCD with AVR MCU.

Those how are building microcontroller based project for little long must have got bored with the good old character LCDs. Whether you are bored or your application require to present more data to the user in a better way, you need Graphic LCD. Character LCD Interfacing is quite easy so every one uses it, but when I comes to Graphic LCD you need a well written and powerful graphic library. Its not enough that you read the LCD datasheet and connect it your MCU and start sending data. Because the LCD just appears to be block of memory whose contents are directly visible on screen. The datasheet can only guide you how to access this memory. You just can’t do much by writing to the memory. The graphic library is a piece of software that has complex algorithms to render graphic primitives like line, rectangles, circles, images and more. It also helps load fonts and render text and numbers on screen. So it provide high level access to the LCD screen and applications can be written much more easily. While I was researching for graphic library for the GLCDs, I found some but I was not fully satisfied by any of them. So I began to write a clean, powerful, portable and easy to use library that can handle sever […]

Interfacing MMA7260 Triple Axis Accelerometer with ATmega32 – AVR Tutorial

Accelerometers are recently developed solid state electronics devices that makes it very easy to measure acceleration. They are completely modular and very tiny devices which gives voltage proportional to acceleration. These type are called analog accelerometers as their output is voltage. Some other gives a PWM output or direct binary digital data, they are called digital accelerometers. Accelerometers are used widely in modern devices. Apple iPhone,iPad and Nokia series 60v5 devices for automatic screen orientation changing. Also for motion gaming and other showoff stuff like Xpress Beer in above devices. Portable Hard disk and Notebooks for fall detection. Anti-theft devices. Motion Gaming Consoles like Nintendo Wii. Balancing Robots and UAVs. Experiments which needs to find force, like car crash experiments. And Possibly many other. Accelerometers can measure acceleration in 2 dimensional or 3 dimensional space. They are called 2D and 3D accelerometers respectively. Accelerometers have certain range, i.e. the maximum acceleration they can measure. It is specified in terms of g. ‘g’ is the acceleration due to gravity of earth and it is equal to 9.80665m/s2. Common accelerometers can have a range of 1.5g to 6g. It is obvious that 1.5g accelerometer is more precise than 6g. So use 1.5g where more accuracy is needed while use 6g for much more harsh experiments. Renault R26 can pick up 100km/hr is […]

Interfacing LM35 Temperature Sensor with PIC Microcontroller.

The are many cool sensors available now a days, ranging from IR distance sensor modules, accelerometers, humidity sensors, temperature sensors and many many more(gas sensors, alcohol sensor, motion sensors, touch screens). Many of these are analog in nature. That means they give a voltage output that varies directly (and linearly) with the sensed quantity. For example in LM35 temperature sensor, the output voltage is 10mV per degree centigrade. That means if output is 300mV then the temperature is 30 degrees. In this tutorial we will learn how to interface LM35 temperature sensor with PIC18F4520 microcontroller and display its output on the LCD module. First I recommend you to go and read the following tutorial as they are the base of this small project. Interfacing LCD Module with PIC Microcontrollers. Making the LCD Expansion Board for PIC18F4520. Using the ADC of PIC Microcontrollers. After reading the ADC tutorial given above you will note the the PIC MCU’s ADC gives us the value between 0-1023 for input voltage of 0 to 5v provided it is configured exactly as in the above tutorial. So if the reading is 0 then input is 0v, if reading is 1023 then input is 5v. So in general form if the adc read out is val then voltage is. unsigned int val; val=ADCRead(0); //Read Channel 0 voltage= […]

Using the ADC (Analog to Digital Converter) of PIC Microcontroller

Many electrical signals around us are Analog in nature. That means a quantity varies directly with some other quantity. The first quantity is mostly voltage while that second quantity can be anything like temperature, pressure, light, force or acceleration. For example in LM35 temperature sensor the output voltage varies according to the temperature, so if we could measure voltage, we can measure temperature. But most of our computer (or Microcontrollers) are digital in nature. They can only differentiate between HIGH or LOW level on input pins. For example if input is more than 2.5v it will be read as 1 and if it is below 2.5 then it will be read as 0 (in case of 5v systems). So we cannot measure voltage directly from MCUs. To solve this problem most modern MCUs have an ADC unit. ADC stands for analog to digital converter. It will convert a voltage to a number so that it can be processed by a digital systems like MCU. This enables us to easily interface all sort of analog devices with MCUs. Some really helpful example of analog devices are Light Sensors. Temperature Sensors. Accelerometers. Touch Screens. Microphone for Audio Recording. And possibly many more. In this tutorials we will learn to use the internal ADC of PIC18 devices (Example is for PIC18F4520 which is […]

Remote Controlled Fan Regulator using ATmega8

This device can be used to remotely control the speed of an AC fan and to switch it on or off. The remote control is a cheap NEC Format remote, usually supplied with small DVD players. Three buttons are used to command the circuit. The UP key increase the fan’s speed while the DOWN key decrease it. The ENTER key is used to switch on or off the fan. The unit provides 10 way speed control from 0 to 9. The current speed is displayed in a seven segment display. The yellow LED on the PCB indicates the power status of the load. If the load is switched off using the R/C then the LED will also be switched off. In the Video below you can check out the project in action. The main parts of the circuit is labeled below. The seven segment display used to show the current speed level. The TSOP1738 sensor is used to pick up commands from remote control. The Yellow LED indicates the power status of the load. OUT – Here the AC load is connected in series. Tested on 220v 50Hz AC line. IN – Power supply from a 12-0-12 transformer is applied here. MCU – ATmega8 AVR 8 bit Microcontroller. SWITCH – Manual Switch used to operate the unit without the remote […]