Skip to content

Commit

Permalink
Create code.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrdecent08 authored Apr 2, 2022
1 parent eac29fb commit f1df6b7
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Fade/code.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
int led = 13; // the PWM pin the LED is attached to
int pResistor = A0; // the Photo Resistor Pin
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by

void setup(void)
{
//Serial.begin(9600);
pinMode(pResistor, INPUT);
pinMode(led, OUTPUT);
}

void loop(void)
{
brightness = analogRead(pResistor);
//Serial.println(brightness, DEC);
// set the brightness of pin 9:
//analogWrite(led, brightness);

// change the brightness for next time through the loop:
//brightness = brightness + fadeAmount;

// reverse the direction of the fading at the ends of the fade:
if (brightness == 0){
digitalWrite(led, HIGH);
delay(10);
digitalWrite(led, LOW);
delay(10);
}
else{
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
// wait for 30 milliseconds to see the dimming effect

}

0 comments on commit f1df6b7

Please sign in to comment.