I'm working on a design project and I'm pretty new to Arduino so any help I can get would be super helpful...the scope is I want 4 sets of LEDs to be controlled separately by PIR motion sensors and LDRs so that when it is dark, the LEDs will brighten and vice versa. The PIRs would activate the LEDs when there is motion. I've adapted some codes to get my LDRs to control my LEDs but its doing the reverse effect of what I want. They are getting brighter when there is more light and darker when I cover it...I also don't know how to incorporate the motion sensors into the code. Any guidance would be great! This is the code I've got so far:
#define LDR 3,2,4,10
#define LED 9,10,11,12
#define PIR 5,6
int val;
void setup() {
Serial.begin(9600);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
pinMode (11, OUTPUT);
pinMode (12, OUTPUT);
}
void loop() {
{int value = analogRead(3);
if (value > 50) value = 225;
if (value < 50) value = 10;
analogWrite(9, value);
}
{
val = analogRead(3);
Serial.print("Before map: {");
Serial.print(val);
Serial.println("}");
analogWrite(9, val);
}
{int value = analogRead(2);
if (value > 50) value = 225;
if (value < 50) value = 10;
analogWrite(10, value);
}
{
val = analogRead(2);
Serial.print("Before map: {");
Serial.print(val);
Serial.println("}");
analogWrite(10, val);
}
{int value = analogRead(4);
if (value > 50) value = 225;
if (value < 50) value = 10;
analogWrite(11, value);
}
{
val = analogRead(4);
Serial.print("Before map: {");
Serial.print(val);
Serial.println("}");
analogWrite(11, val);
}
{int value = analogRead(10);
if (value > 50) value = 225;
if (value < 50) value = 10;
analogWrite(12, value);
}
{
val = analogRead(10);
Serial.print("Before map: {");
Serial.print(val);
Serial.println("}");
analogWrite(12, val);
delay(1000);
}
}