CCCPaste

Arduino Automation rev_01

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: Arduino Automation
	- Source Code compiled for: Arduino Nano
	- Source Code created on: 2024-01-09 22:09:43

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* eğer ldr sensörü Okunan ışık değeri 35'den küçük */
	/* ise  led %20 parlaklıkla yansın bu durumda led */
	/* yanıyorken harekeret sensöründen hareket */
	/* algılanırsa parlaklık seviyesi %100 olsun eğer bu */
	/* durumdayken hareket algılanmazsa led % 20 */
	/* parlaklıkla yanm */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t led_LED_PIN_D2 = 2;
const uint8_t ldr_SENSOR_PIN_A0 = A0;
const uint8_t motion_SENSOR_PIN_D3 = 3;

void setup(void)
{
  // put your setup code here, to run once:
  pinMode(led_LED_PIN_D2, OUTPUT);
  pinMode(ldr_SENSOR_PIN_A0, INPUT);
  pinMode(motion_SENSOR_PIN_D3, INPUT);
}

void loop(void)
{
  // put your main code here, to run repeatedly:
  
  // Read the light intensity from the LDR sensor
  int lightIntensity = analogRead(ldr_SENSOR_PIN_A0);
  
  // Check if the light intensity is less than 35
  if (lightIntensity < 35) {
    // Set the LED brightness to 20%
    analogWrite(led_LED_PIN_D2, 51);
    
    // Check if motion is detected by the motion sensor
    if (digitalRead(motion_SENSOR_PIN_D3) == HIGH) {
      // Set the LED brightness to 100%
      analogWrite(led_LED_PIN_D2, 255);
    }
  }
  else {
    // Set the LED brightness to 20%
    analogWrite(led_LED_PIN_D2, 51);
  }
  
  // Add a delay to avoid continuous readings
  delay(100);
}