Opto Switch Slotted Sensor Shield and Arduino


I intend to use this board in an NBTV project to measure the speed of the Nipkow disk. This is normally done by having slots cut in the disk and shining an IR LED through to be picked up by a photo diode on the other side.

The connections (looking down on the board with the connections at the bottom) are Gnd, Analog Output, Digital Output and Vcc. I have used a slightly modified sketch that I used with an LDR shield. Arduino Analog Pins A0 and A3 are set as Digital Output Pins to provide the power supply. Pin A1 is set as a Digital Input and pin A2 is set as an Analog Input.

Upload the sketch, then remove the power, connect the shield as shown in the picture above and reconnect the power and the PWR LED will light. Use a piece of card to interrupt the beam, the Output LED will turn Off and On, the Serial Monitor Output is shown here.


When the beam is broken the Output goes High and the OUT LED lights up. When using this as a Tachometer the Digital output would normally be used. Here is the sketch I used to test the board, but before using it make sure your connections are the same as mine.

* Opto Slotted Switch Test Sketch
* Pins
* Vcc to A0
* DO to A1
* AO to Arduino pin A2
* Gnd to A3

int analog = 16; // Arduino A2
int digital = 15; // Arduino A1
int gnd = 17;  // supplies 0 volts
int power = 14;  // supplies 5 volts

void setup() {
 Serial.begin(9600); // start Serial Monitor
 pinMode(13, OUTPUT);
 digitalWrite(13,LOW);  // turn OFF the LED on Arduino pin 13
 pinMode(digital, INPUT);  // this pin reads the digital output, either HIGH or LOW
 pinMode(power, OUTPUT);
 digitalWrite(power,HIGH);// this pin will supply 5 volts
 pinMode(gnd, OUTPUT);
 digitalWrite(gnd,LOW); // this pin will supply the GND to the board

void loop() {
 // print the analog output in milli volts
 Serial.print("Analog level = ");
 Serial.println(" mv");  // milli volts
 // print the digital Output LOW = alarm tripped
 Serial.print("Digital level =");
 if (digitalRead(digital) == HIGH){
   Serial.println(" HIGH");
   Serial.println(" LOW");
 delay (1000);  // this just makes it easier to read the serial output


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: