Home Theater

Made by hlgraffeo

Used for connected home theater systems

Created: January 28th, 2015

0

Connected Home Theater System:

This project envisions a connected home that interacts with your couch, your entertainment, and you in-home lighting. Once you sit down on your couch, your entertainment system boots up. This is represented as an LED in this system. Then, if you are seated in the home theater, and the internal lights dim, the external lights lower allowing for hallway or external lighting to not interfere with your entertainment experience.

Materials Used:

2 1k ohm resistors

2 10k ohm resistors

1 FSR resistor

1 photoresistor

2 single color LEDs

Spark core

Breakboard

jumpers




0
0
// Define fsr pin
int fsrPin = A0;

// Create a variable to hold the FSR reading
int fsrReading = 0;

// Define fsrLED
int ledPin1 = D0;

// LED brightness.
int ledBrightness1 = 0;

// Define photoCell
int photoCellPin = A1;

// Create a variable to hold the light reading
int photoCellReading = 0;

// Define photoLED
int ledPin2 = D1;

// Create a variable to store the LED brightness
int ledBrightness2 = 0;

void setup()
{
  // Set up the LED for output
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
   // Create a cloud variable of type integer
  // called 'light' mapped to photoCellReading
  Spark.variable("force", &fsrReading, INT);
  Spark.variable("light", &photoCellReading, INT);

}

void loop()
{

  if ( fsrReading > 0 ){
    ledBrightness2 = map(photoCellReading, 0, 4095,455, 0);
    photoCellReading = analogRead(photoCellPin);

  }


  // fade the LED to the desired brightness
  analogWrite(ledPin2, ledBrightness2);

  // wait 1/10th of a second and then loop
  delay(100);

  // Use analogRead to read the photo cell reading
  // This gives us a value from 0 to 4095
  fsrReading = analogRead(fsrPin);

  // Map this value into the PWM range (0-255)
  // and store as the led brightness
  ledBrightness1 = map(fsrReading, 0, 4095, 0, 255);

  // fade the LED to the desired brightness
  analogWrite(ledPin1, ledBrightness1);

  // wait 1/10th of a second and then loop
  delay(100);

}
Click to Expand
x
Share this Project


About

Used for connected home theater systems