Created
July 15, 2016 15:43
-
-
Save shawngrimes/b31c0763761d827c3d08fadca83fd623 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ledPin=9; //Variable to store pin of LED | |
int photoPin=A0; //Variable to store pin of potentiometer | |
int photoValue=0; //Variable to store last known value of potentiometer | |
int brightnessValue=0; //Variable to store LED brightness | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(ledPin, OUTPUT); //Setup LED pin for output | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
photoValue=analogRead(photoPin); //Read the value of the potentiometer pin | |
brightnessValue=map(photoValue,0,1023,0,255); //Map the potentiometer value to a brightness | |
analogWrite(ledPin,brightnessValue); //Set the brightness of the ledPin | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment