Skip to content

Instantly share code, notes, and snippets.

@KaiaKitten
Created May 26, 2015 22:17
Show Gist options
  • Save KaiaKitten/af128f95b3f298935af6 to your computer and use it in GitHub Desktop.
Save KaiaKitten/af128f95b3f298935af6 to your computer and use it in GitHub Desktop.
Arduino Photorecptor code
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