Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the ignition domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /dom953964/wp-includes/functions.php on line 6131

Deprecated: Return type of GD_WordPress_File_Iterator_Filter::accept() should either be compatible with FilterIterator::accept(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /dom953964/wp-content/plugins/wp_migration-master/classes/iterators.php on line 5

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the health-check domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /dom953964/wp-includes/functions.php on line 6131
The Darker, the Brighter it is – Lara Grant

The Darker, the Brighter it is

INPUT: Photoresistor
OUTPUT: LED

DESCRIPTION: Control the brightness of the LED with the amount of light. The darker it is, the brighter the LED.

[code lang=”arduino” light=”true”]
//adafruit.net

int photocellPin = A6; // the pin the photocell is on
int photocellReading; // the sensor reading
int LEDpin = 5; // pin LED is on (PWM pin)
int LEDbrightness; //

void setup(void) {
// We’ll send debugging information via the Serial monitor
Serial.begin(9600);
}

void loop(void) {
photocellReading = analogRead(photocellPin);

Serial.print("Analog reading = ");
Serial.println(photocellReading); // the raw analog reading – read your values and plug them into the map function
//Serial.println(LEDbrightness); // after mapping
// LED gets brighter the darker it is at the sensor
// that means we have to -invert- the reading from 0-1023 back to 1023-0
photocellReading = 30 – photocellReading;
//now we have to map 0-1023 to 0-255 since thats the range analogWrite uses
LEDbrightness = map(photocellReading, 0, 30, 0, 255);

analogWrite(LEDpin, LEDbrightness);

delay(10);
}
[/code]

Leave a Reply