> For the complete documentation index, see [llms.txt](https://htooaunklinn-organization.gitbook.io/htooaunklinn-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://htooaunklinn-organization.gitbook.io/htooaunklinn-docs/hardware-and-iot/arduino-on-macos/page-3.md).

# Page 3

<figure><img src="https://3422137941-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ1pJMMB2xXaxqLgUEeCs%2Fuploads%2F7ZDFs9VynR2bPmpv9Nua%2Fee.png?alt=media&amp;token=5214d590-1498-4e3c-82dc-56d6d576f8c8" alt="" width="375"><figcaption></figcaption></figure>

```cpp
int ldrPin = A0;
int ledPin = 13;
int threshold = 55;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(ldrPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  int ldrValue = analogRead(ldrPin);
  Serial.println(ldrValue);

  if (ldrValue < threshold) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }

  delay(100);
}
```
