Curtains variation

Made by queenien2000

Created: January 28th, 2015


The scenario

There are two layers of curtains in the room. Using two TMP36 sensors controls the curtains’ interaction. One sensor records the temperature variation in the center of the room and reflects the data on the first layer curtain, which means that the curtain would show different height according to the data.

Another sensor monitors the temperature of the curtain wall and the data will change the second layer’s curtain height. When the temperature is 35 degree Celsius or over, the curtain would be dropped down completely.

The circuit includes

● Spark Microcontroller

● Breadboard

● Jumper Wires

● Two TMP36 sensors

● Two 0.01uF (10nF) ceramic capacitors



int tempPin1 = A0;
int tempPin2 = A7;

// Create a variable that will store the temperature value
double temperature = 0.0;

void setup()
  // Register a Spark variable here
  Spark.variable("temperature", &temperature, DOUBLE);

  // Connect the temperature sensor to A0 & A7 and configure it
  // to be an input
  pinMode(A0, INPUT);
  pinMode(A7, INPUT);

void loop()
  int reading = 0;
  double voltage = 0.0;

  // Keep reading the sensor value so when we make an API
  // call to read its value, we have the latest one
  reading = analogRead(A0,A7);

  // The returned value from the Core is going to be in the range from 0 to 4095
  // Calculate the voltage from the sensor reading
  voltage = (reading * 3.3) / 4095;

  // Calculate the temperature and update our static variable
  temperature = (voltage - 0.5) * 100;

  // write to the appropriate pin
  digitalWrite(A7, state);

  // condition: only if the temperature is 100, the A0 sensor will record the data
  if (A0)state > 35;

  // write to the appropriate pin
  digitalWrite(A0, state);
Click to Expand