Arduino Proximity Shield acts as Arduino Shield via 1Sheeld

Buy 1Sheeld
1Sheeld proximity sensor shield

Use the proximity sensor in your smartphone and take a certain action if something or someone gets near your
phone.

This shield is one of the sensor shields. Sensor shields allows you to tap into your smartphone’s sensors and use in prototyping with Arduino, you can get information from the surrounding environment and use
it to trigger a certain action.Learn more from the sensor shields tutorial.

Proximity sensor allows your Arduino to check if there’s an object interrupted the sensor and take certain actions.

Adding #define CUSTOM_SETTINGS along with #define INCLUDE_PROXIMITY_SENSOR_SHIELD is a key that will let you unlock proximity sensor shield only among all shields, preventing 1Sheeld library from eating your memory especially for UNO board.

byte getValue(void)

Gets value of smarpthone’s proximity.
Note: Values of proximity doesn’t come as centimeters readings,it just comes as a 1 or 0 as a state of yes or no condition if the proximity sensor was interrupted or not, most of the phones sense if only an object gets near the proximity sensor just to turn of the display and touch so it won’t make random actions, a byte is returned as there are phones sense distance varries from each other some sense at 1cm others at 5cm, so it depends on the phones manufacturer(like calling and getting the phone near your ear the phone turn off the touch and display).

 

SYNTAX
ProximitySensor.getValue();

 

RETURNS
Returns a byte holding the distance the proximity sensor senses the interrupt.

 

PARAMETERS
None.

 

USAGE
byte prox = Proximity.getValue();

 

void setOnValueChange(void(*userFunction)(byte))

Sets a certain individual function written by the user in the sketch to be called and runs its functionality once an object interrupts the proximity sensor and sent by the application to the Arduino.

 

SYNTAX
Proximity.setOnValueChange(&userFunctionName);

 

RETURNS
None.

 

PARAMETERS
&userFunctionName: takes the physical address of the userFunction in the memory and jump to it once called to execute it’s functionality.

 

USAGE
Proximity.setOnValueChange(&myFunction);
/* myFunction exists under the loop function. */
/* This function will be invoked each time an object interrupts the sensor. */
void myFunction(byte proximitySense)
{
      if(proximitySense)
       {
          /* Turn on the LED. */
          digitalWrite(ledPin,HIGH);
       }
}