Ingo Lohs
Published © LGPL

Light barrier - how it works

A light barrier removed from a printer and led to the start

BeginnerProtip9 minutes250
Light barrier - how it works

Things used in this project

Hardware components

light barrier
×1
Arduino Nano R3
Arduino Nano R3
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
4 pieces m/m
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

light barrier - example

C/C++
// 5V   = values round about 1019-1021 
// 3.3V = values round about  752- 758

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
   
  if (sensorValue <=100) {
   Serial.print(sensorValue);
   Serial.println(" - thing blocking");
  } else {
   Serial.print(sensorValue);
   Serial.println(" - NO thing blocks");  
  }
 
}

Credits

Ingo Lohs

Ingo Lohs

149 projects • 135 followers
I am well over 40 years and come from the middle of Germany.

Comments