Little Bird Curriculum / code littlebird.com.au
vce_u1_03_read_ldr.ino Arduino (C/C++) 14 lines · 4 views ✦ Open in English IDE Raw Download Embed view

Read a light-dependent resistor on A0 and print the raw ADC value once a second.

From the unit VCE Systems Engineering Unit 1 — Electrotechnological systems design · activity PRP 3: Light sensing with an LDR
// PRP 3 — light sensing with an LDR.
// Wire the LDR and a fixed resistor as a divider, junction to A0.

const int LDR_PIN = A0;

void setup() {
  Serial.begin(9600);
}

void loop() {
  int reading = analogRead(LDR_PIN);   // 0-1023, NOT a light level yet
  Serial.println(reading);
  delay(1000);
}

Embed this snippet

As an iframe:

Or drop it inline with a script tag (injects the highlighted block where included):

Shared from Little Bird Electronics curriculum.

Copied to clipboard