Evolution of a Blog

This blog has evolved as I have as a maker. It starts at the beginning of my journey where I began to re-tread my tires in the useful lore of micro electronics and the open-source software that can drive them. While building solutions around micro-electronics are still an occasional topic my more recent focus has been on the 3D Printing side of making.

Saturday, September 29, 2012

Proximity Detection

The Explorer PCB has an infrared proximity sensor at each of it's four corners.   This consists of three little LEDs (or LED like things).   Two of them are side by side hanging from under the board.   One of these is the IR emitter and the other is the reader.  On the top of the board is a little LED that lights when the IR emitter is active (since you can't see IR).

Power for these sensors is provided by the board so connecting them is a matter of four wires from the board to digital pins on the Arduino for triggering the IR and another four to analog input pins for reading the proximity.


The code below shows my test code reading the Right Front corner.   Note that this code is based on my Python to Arduino Interface but is 1-1 analogous to what you would code in Arduino directly.

    import time
    from Py2Ard import interfaceClass

    # Instantiate the interface class    
    my_board = interfaceClass('/dev/ttyUSB0')
     # Pin assignments for  operations 
    TriggerRF = 36 
    InputRF = 10 
    # Set the pin modes
    while 1==1:
    # Turn on the infra red

        # Take a reading
    reading = int(my_board.returnValue)
    # Turn off the infra red
    # Take a reading (this will be the ambient light)
    ambient = int(my_board.returnValue)
    # Subtract ambient for your proximity reading
    print "RF = " + str(reading - ambient)

No comments:

Post a Comment