I bought 10 photo interrupters, thinking I might need them to zero stepping motor positions.
uxcell 10 Pcs 1/8 inches Slot PCB Photo Interrupter Slotted Optical Sensor Switch HY860N (No longer available)
#define PI_LED 4 int detectorVal = 0; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); pinMode(PI_LED, OUTPUT); digitalWrite(PI_LED, HIGH); } void loop() { // put your main code here, to run repeatedly: digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(500); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for a second detectorVal = analogRead(A0); Serial.println(detectorVal); }