03-04 PhotoInterrupter
From Manuals
(Difference between revisions)
| Line 1: | Line 1: | ||
| - | A simple program to test KTIR slotted optosensor. It switches an LED according to state of sensor | + | A simple program to test KTIR slotted optosensor. It switches an LED according to state of sensor. |
| - | + | The signals used for this example are listed below: | |
| + | {| border="1" cellpadding="5" cellspacing="2" align="center" style="text-align: center;" | ||
| + | |+ align="bottom"|'''Signals Used and Connector Locations for Example 03-04''' | ||
| + | |'''Signal''' | ||
| + | |'''LPC4330 PIN NAME''' | ||
| + | |'''BAM210E''' | ||
| + | |'''BAM210''' | ||
| + | |'''BAM200E''' | ||
| + | |'''BAM200''' | ||
| + | |'''Used for''' | ||
| + | |- | ||
| + | |D0 | ||
| + | |P6_5 | ||
| + | |J9-1 | ||
| + | |J9-1 | ||
| + | |S2-5 | ||
| + | |S2-5 | ||
| + | |LED | ||
| + | |- | ||
| + | |D2 | ||
| + | |P1_7 | ||
| + | |J9-3 | ||
| + | |J9-3 | ||
| + | |S3-7 | ||
| + | |S3-7 | ||
| + | |Photo Interrupter | ||
| + | |- | ||
| + | |} | ||
| + | |||
| + | The following schematic can be used to build the circuit with a BAM210E or BAM210. | ||
[[Image:BAM210_03_04_SCH.png|center|alt=BAM210|frame|<div align="center">'''Schematic for example 03-04''']] | [[Image:BAM210_03_04_SCH.png|center|alt=BAM210|frame|<div align="center">'''Schematic for example 03-04''']] | ||
| Line 22: | Line 51: | ||
} | } | ||
| - | The following image shows the built circuit. | + | The following image shows the built circuit on a BAM210E. |
[[Image:BAM210_PhotoInt.jpeg|center|]] | [[Image:BAM210_PhotoInt.jpeg|center|]] | ||
Current revision as of 17:58, 17 September 2014
A simple program to test KTIR slotted optosensor. It switches an LED according to state of sensor.
The signals used for this example are listed below:
| Signal | LPC4330 PIN NAME | BAM210E | BAM210 | BAM200E | BAM200 | Used for |
| D0 | P6_5 | J9-1 | J9-1 | S2-5 | S2-5 | LED |
| D2 | P1_7 | J9-3 | J9-3 | S3-7 | S3-7 | Photo Interrupter |
The following schematic can be used to build the circuit with a BAM210E or BAM210.
/*Program Example 3.4: Simple program to test KTIR slotted optosensor. Switches an LED according to state of sensor
*/
#include "mbed.h"
DigitalOut redled(D0);
DigitalIn opto_switch(D2);
int main()
{
while(1) {
if (opto_switch==1) //input = 1 if beam interrupted
redled = 1; //switch led on if beam interrupted
else
redled = 0; //led off if no interruption
} //end of while
}
The following image shows the built circuit on a BAM210E.


