Go Down

Topic: thermometer with lm35 and 7 seg. my first project (Read 890 times) previous topic - next topic

tryingtechtordon

I just started playing with my new arduino yesterday, I am just a plumber and have no clue what I am doing. but i managed to put together some code by looking at examples and trying stuff out.
      so what do you think of my first project?.

material
         LM35 TEMP SENSOR
         4 DIGIT 7 SEGMENT DISPLAY
         ARDUINO UNO
         4 RESISTERS (NOT SURE WHAT ONES I USED)
         WIRES

I downloaded the 7 segment library from here, and hooked up the wires the way it said to.






                            float val;
                            int tempPin = 1;


 
 #include "SevSeg.h"
 SevSeg sevseg; //Instantiate a seven segment object
 
 void setup() {
   byte numDigits = 4;
   byte digitPins[] = {2, 3, 4, 5};
   byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
   sevseg.begin(COMMON_CATHODE, numDigits, digitPins, segmentPins);
}

void loop()
{



                            val = analogRead(tempPin);
                            float mv = ( val/1024.0)*5000;
                            float cel = mv/10;
                            float farh = (cel*9)/5 + 32;




 
    sevseg.setNumber(cel,1); // Displays '3.141'

     sevseg.refreshDisplay();

     sevseg.setBrightness(90);

     


     }



it actually works, only the last digit after the decimal cant seem to make up its mind on what number to be.

be kind in the comments lol. this is my first time lol.

Go Up