Learn To Write Code For 8051, Arduino, AVR, dsPIC, PIC, STM32 ARM Microcontroller, etc.
Coding Embedded Controller With C/C++.
Printed Circuit Board (PCB) Project For Electronics Hobbyists.
ATMega32 Interfaces To LM35 And 16x2 Character LCD
Overview
In some previous post, I have wrote some posts about analog to digital convert. This peripheral converts any analog output devices and converter them to digital value. Some analog output sensor like LM35 creates an analog voltage output linear to its 10 mV step temperature value.
A display device show the information or status of the MCU and other input output devices. I posted some examples on using the industrial standard HD44780 LCD controller.
Example Program
In this example post, ATMega32 reads the analog temperature value and just display this information to the display. The temperature is in both degree Celsius and degree Fahrenheit.
Interfacing And Programming
LM35 connects to the analog input pin ADC7 - the user could select any analog pin within its 8 analog inputs. The MCU clocks at 16 MHz due to a pre-soldered crystal on the learning board. However, I set the ADC conversion clock rate to 1:128.
LM35DZ in TO-92 Package
The display operates in 4-bit interfacing mode. A single PORTD of the MCU is sufficient to do this task.
Schematic Diagram
C source code of this example lists below, click here to download a zip archive.
Note: Without configuring the sprintf() function in the project property, it can't convert the float data type to string value. We must the project properties as follow.
Open the project properties by pressing ALT+F7.
Tick the required tick box as shown in the picture
Fill the required link flag
Fill the text box with this string "-lprintf_flt"
Then we can use the sprintf() function with float data type properly. If you still have the problem with sprintf(), see this link because I got it work from there.
No comments:
Post a Comment