Examples - Electronic Bricks - Electronic Analog Temperature

Get access to the analog Temperature Brick.

That program gives you a basic understanding of how to use the analog Temperature Brick. Just connect it to analog input port (1) on your micro-controller.

/*
Example: How to use the 'Analog Temperature Sensor Electronic Brick'
Usage: Connect Brick to analog pin 5 on the Seeduino Shield
*/
// Define the analog input pin for sensor
int sensorInputPin = 5;
// Storage variable
int temperature = 0;
// Just take a look in the datasheet or compare to another calibrated temp.sensor
int calibrationFactor = 252;
void setup()
{
        Serial.begin(9600);                 // Invoke Serial Interface for debugging purposes
}

void loop()
{
        // Read the sensor
        int temp = analogRead(sensorInputPin);
        // Calculate C* out of analog reading (please play around with n)
        temperature = (temp + calibrationFactor -500) /10;
        // Output to console or computer
        Serial.println(temperature);
        delay(500);
}