// https://www.youtube.com/watch?v=po_lHVKFQWI
// http://heliosoph.mit-links.info/photointerrupter-basics/

/*
+5V --220 Ohm--      ---- GND
              |      |
              +      D
              TCST2103
              E      +
              |      |
       GND ----      ----10kOhm---- +5V
                     |
                     |
                     ----A0 PIN
*/


int sensorPin = A0;
int sensorValue = 0;
int ledPin = LED_BUILTIN;
 
void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}
 
void loop() {
  sensorValue = analogRead(sensorPin);
  Serial.println(sensorValue);

  if (sensorValue > 512) {
    digitalWrite(ledPin, HIGH);
  }
  else { 
    digitalWrite(ledPin, LOW);
  }
  
  delay(200);
}
