Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Test phototransistor
// phototransistor test
int pt = A0;
int led = 11;
int val = 0;
void setup() {
// analog in
pinMode(pt, INPUT);
// pwm out
pinMode(led, OUTPUT);
// begin serial
void loop() {
// read from analog pin
val = analogRead(pt);
// print to serial
// fade led in sync with analog read (map to pwm range)
analogWrite(led, map(val, 0, 1023, 0, 255));
// 10 fps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.