# Pumpkin Night Light

22

reference by https://www.instructables.com/id/LED-Pumpkin-Light-controlled-by-Arduino/

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## Step 1: What You Need

a pumpkin

1 x Arduino

1 x LED

1 x LDR

1 x 1000 ohm resistor

1 x 220 ohm resistor

## Step 2: Build a Circuit

solder the 220 ohm resistor to the short leg of the LED and insert it in the ground pin.Insert the long leg into digital pin 9.Insert one wire from the LDR and one leg of the 1000 ohm resistor into analog pin 3insert the other end of the LDR in 5v, and the other end of the 1000 ohm resistor into the second ground.

## Step 3: Write a Program

int ledPin = 9;//

int val = 0;

int cycle = 750;

int value = 0;

void setup() //

{

pinMode(ledPin, OUTPUT);

Serial.begin(9600);

}

void loop() //

{

if (cycle > 700)

{

}

if (value > 650)

{

cycle++;

val = random(256);

analogWrite(ledPin, val);

if (val > 250)

delay (val * random(3));

else if (val < 2)

if (cycle > random(800, 3500))

{

for (val = 250; val > random(20, 40); val--)

{

analogWrite(ledPin, val);

delay(random(2, 14));

}

analogWrite(ledPin, val);

delay(random(10, 1000));

cycle = 0;

}

}

else { digitalWrite(ledPin, LOW);

delay(10000);

}

}

## Step 5: Light Up the Pumpkin

put the circuit back in the pumpkin and shut the light off and light it up

153 7.2K
11 850
59 3.3K