Hey Guys,
I'm building a lighting feature for my dissertation, I've finished my code, below if your interested.
I'm looking to turn the prototype into an actual light.
Does anyone have any advice for turning the breadboard into an actual product?
I'm unsure of what wires I need to replace the jumper wires, as the distance between the arduino and the actual light could be quite a distance in a live situation..
Also, does anyone know how many LED's you could power off of an Arduino Uno? I'm hoping to use at least 15-20
I'm currently using 3mm Blue Diffused LED 5k MCD, but I'm looking to change these to 1.8-2.4v Red LED's...
Any help appreciated,
Thanks
Sam
// LED gets brighter the less light the LDR recieves
#define LED1 9 // pin that LED is attached to
#define LED2 10
#define LED3 11
#define LED4 6
int Val = 0; // variable used to store the value coming from the sensor
int ledState = LOW; // ledState used to set the LED
long previousMillis = 0; // will store last time LED was updated
long randNumber;
void setup() {
pinMode(LED1, OUTPUT); // LED is an OUTPUT
pinMode(LED2, OUTPUT); // LED is an OUTPUT
pinMode(LED3, OUTPUT); // LED is an OUTPUT
pinMode(LED4, OUTPUT); // LED is an OUTPUT
randomSeed(analogRead(2 & 3));
// Analogue pins are autmatically set as inputs
}
void loop() {
// READ SENSOR INOUT
if ((Val = analogRead(0)) < 200) // read the value from the sensor
// HIGHER NUMBER = MORE SENSITIVE
// LOWER NUMBER = LESS SENSITIVE
{
analogWrite(LED1, 255-Val); // turn LED on at brightness set by sensor value
analogWrite(LED2, 255-Val);
analogWrite(LED3, 255-Val); // turn LED on at brightness set by sensor value
analogWrite(LED4, 255-Val);
delay(10); // stop the program for some time
}
else if ((Val = analogRead(0)) > 200)
{ //RANDOMLY BLINK LED 1
randNumber = random(0, 150000);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > randNumber) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(LED1, ledState);
//END OF RANDOM BLINK
}
{ // RANDOMLY BLINK LED 2
randNumber = random(0, 100000);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > randNumber) {
// save the last time you blinked the LED
previousMillis = currentMillis;
digitalWrite(LED2, ledState);
if (ledState == HIGH)
ledState = LOW;
else
ledState = HIGH;
// END OF RANDOM BLINK
}
{ // RANDOMLY BLINK LED 3
randNumber = random(0, 100000);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > randNumber) {
// save the last time you blinked the LED
previousMillis = currentMillis;
digitalWrite(LED3, ledState);
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// END OF RANDOM BLINK
}
{ //RANDOMLY BLINK LED 4
randNumber = random(0, 150000);
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > randNumber) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
// set the LED with the ledState of the variable:
digitalWrite(LED4, ledState);
//END OF RANDOM BLINK
}
}
}
}
}
}