Week 5; Dom Heyland, Toby Nalder

During our final week we have continued to work and refine our code for our array of lights which will illuminate once a light sensor is covered. Playing around with different input and output numbers we where able to achieve a smooth transition from dark to light which looked affective on our light display.

int ledPin = 9;
int potPin = 0;
int minLight = 0;
int maxLight = 600;
int val = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(ledPin, OUTPUT);
  pinMode(potPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(analogRead(potPin));
  val = analogRead(potPin);
  if (val > minLight && val < maxLight)
  {
    val = map (val, minLight, maxLight, 255, 0);
  }
  else
  {
    val = 0;
  }
  analogWrite(ledPin, val);
}

Each LED runs parallel and is control by a single pin. Once our light display had been soldered together, when testing it with the 5volt output each LED was lit. However some where brighter than others, as not all LED’s where the same.

 

img_0366

When it came to including the light sensor into the circuit , once covered not all lights where clearly lit up as shown.

img_0368

 

After trying to fix the code we found that the led step up was the problem due to not all the lights being the same. Because the LED’s we used had different voltage ratings, the resistors we calculated to use were too big to allow enough current through to properly light them up. We then replaced our original setup with a larger breadboard, with all the same LED’s. Using this gave no uncertainties with the connections through our soldering and conductive tape. The 33 ohm resistors are still slightly too large to achieve full brightness, and wouldn’t allow current to any more than 10 LED’s.

 

img_0374

 

img_0375

With our final model, we achieved a good firefly effect, where a field of LED’s hidden behind black fabric, illuminate when the light sensor is covered by a hand so it’s in the dark. The darker it is the brighter the LED’s are thanks to a PWM pin.

Future improvements we would make are to use less powerful resistors allowing more LED’s to shine brighter and to add extra light sensors so that the LED’s can illuminate in an array.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s