Jump to content
43oh

Questions about the MSP430 Tempsensor


Recommended Posts

I am writing a program that is supposed to read the temperature from the MSP430's internal sensor, then display it through the LED's by making the red one blink the 10's digit and the green one blink the 1's digit. Pushing the button should toggle between Farenheit and Celcius, default Fahrenheit. 

 

My question is about the output of the analogRead(TEMPSENSOR) function. I know that the output of the function is an int between 0 and 1023 that maps to a range of 0 to 3 volts. What I don't understand is how that output translates to a temperature.

 

I tested the function by just printing the output of analogRead(TEMPSENSOR) to see what reading it put out, and it fluctuated between 511 and 512 (translating to 1.4819 to 1.4848 volts). 

 

Any help or insight would be much appreciated.

 

Code I have written so far:

void setup()
{
  Serial.begin(9600);
  pinMode(GREEN_LED, OUTPUT);
  pinMode(RED_LED, OUTPUT);
  pinMode(TEMPSENSOR, INPUT);
  pinMode(PUSH2, INPUT_PULLUP);
  
}

void loop()
{
  int Temperature, Units, Tens, t
  
  int Reading = analogRead(TEMPSENSOR);
  
  digitalWrite(GREEN_LED, LOW);
  digitalWrite(RED_LED, LOW);
    
  Serial.println(Reading);
  delay(500);
  
  Temperature = Reading          //Convert the tempsensor reading to a temperature in Fahrenheit 
  
  if (buttonState == LOW)                 
  {
    Temperature = (5/9)(Temperature-32);
  }

  Units = Temperature%10
  Tens = (Temperature-Units)/10
  
  for(t=0, t<Tens, t++)
  {
    digitalWrite(RED_LED, HIGH);
    delay (250);
    digitalWrite(RED_LED, LOW);
    delay(250);  
  }
  delay(5000);
  
  for(t=0, t<Units, t++)
  {
    digitalWrite(GREEN_LED, HIGH);
    delay (250);
    digitalWrite(GREEN_LED, LOW);
    delay(250);  
  }
  delay(5000);
}

Obviously it won't work right now as "Reading" hasn't been converted to "Temperature" yet.

 

Thanks again for any help!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...