Thursday, 11 August 2016

Lesson 6: Activity 3 (Automated Light (LDR))

Activity 3
Automated Light (LDR)

LDR Circuit

Materials Needed:
  • Laptop
  • USB cable
  • Arduino Board
  • 1 x LED
  • 1 x 330Ω
  • 1 x LDR
  • 1 x 10kΩ
  • 6 Jumper Wires
Codes: 

int analogVal;
const int ldrPin = ?;
const int led = 6;
void setup()
{
Serial.begin(9600);
pinMode(led, ?);
}
void loop()
{
analogVal = analogRead(ldrPin);
Serial.println(analogVal);
if (analogVal>800)
{
digitalWrite(led, ?);
delay (500);
}
else
{
digitalWrite(led, LOW);
}
delay(200);
}




No comments:

Post a Comment