I have a huge project due in 2 days and i cant figure it out! I am using a PIC16F917 microcontroller and an LM34 sensor to display the thermometer readings on a seven segment display. I am using the MPLAB IDE program to program the pic, but i do not know how to write the code (I believe it is C Code) in order to get this simple temperature reading on the display. Does anyone have a C Code for my pic and sensor to make this work?
You need to write code for the the following functions :
Read the analogue LM34 voltage (A2D)
Convert the reading to temperature
Convert the temperature value to BCD ( 2 digits)
Convert the BCD to 7 segment code
Refresh the 7 segment displays
Re do the loop
Your school require you to write the code to demonstrate that you have the necessary skills to past your course
Which compiler does your school provide?
yes i know that i have to do that for the code, i am good at wiring just awful at coding. We need to use the C Compiler so C Code would be the only code i would be able to use.
i know its a lot to ask i am really stuck and do not understand this and would love if anyone had sample MPLAB C code for a PIC16F917 even if its for a LM35 sensor.
no i do not know how to have an LCD work, this is my first time and i was just given a seven segment display hooked up correctly and had to find the right code using the LM34 sensor, transistors to act as switches for the seven segment, 1k resistor bank hooked up to the pic and the pic16f917. Then i was told to find the correct code using MPLAB IDE program using C to make it display on the seven segment and i have no idea what to do.
Here's a tutorial on using PIC to drive a seven segment display:
This PDF combined with the other three example projects in gave you in your other thread asking help for the same problem, cross posting, provides all the info you need to finish your project.
ADCON0 = (channel << 3) + 0xC1; <--- this is where you tell the pic where to convert the signal.
as i said before check the datasheet and in there there will be 1 or 2 pages about ADCON0 and ADCON1 read them, understand them, get the correct config on your code.
and i believe... it is pretty much at the end your project
---------- Post added at 18:30 ---------- Previous post was at 18:27 ----------
One quick questions. In the code it has #include <htc.h>. Would i have to download that library because in the MPLAB IDE for the PIC16F917 it doesn't have that library it says.
---------- Post added at 18:30 ---------- Previous post was at 18:27 ----------
One quick questions. In the code it has #include <htc.h>. Would i have to download that library because in the MPLAB IDE for the PIC16F917 it doesn't have that library it says.
Ok I got that problem fixed. One quick question though, looking at the code it looks like the seven segment display is connected to port D. Is that correct?