Home Theater

Made by hlgraffeo

The purpose was to create a connected home entertainment system.

Created: January 27th, 2015

0

Project Purpose:

To create a smart, connected, home entertainment system that would accurately detect user presence through the utilization of a force sensing resistor, translate that information through the code, and lower hallway lights when someone is present and other lights in the room go down. 

Materials Used:

Sparkcore & Breadboard

Two single color LEDs

One photoresist0r

One force sensing resistor

Two 10KΩ Resistors

Two 1kΩ Resistors

Lots of jumpers



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
0
x
Share this Project


About

The purpose was to create a connected home entertainment system.