Created
May 26, 2015 22:17
-
-
Save KaiaKitten/af128f95b3f298935af6 to your computer and use it in GitHub Desktop.
Arduino Photorecptor code
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
const int RLED = 9; | |
const int LIGHT = 0; | |
const int MIN_LIGHT = 200; | |
const int MAX_LIGHT = 900; | |
int val = 0; | |
void setup() { | |
pinMode(RLED, OUTPUT); | |
} | |
void loop() { | |
val = analogRead(LIGHT); | |
val = map(val, MIN_LIGHT, MAX_LIGHT, 255, 0); | |
val = constrain(val, 0, 255); | |
analogWrite(RLED, val); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment