Amr Saleh
Published © MIT

Foursquare ultrasonic checkin

You can check in to home / office or even your grandma's house by simply walking in front of an ultrasonic sensor.

BeginnerShowcase (no instructions)1,194
Foursquare ultrasonic checkin

Things used in this project

Schematics

Circuit diagram

it's ok to connect ultrasonic sensor at any pins but you must change them in code.

Code

Arduino Code

C/C++
the ultrasonic used is connected using 4 wire jumpers not the traditional ping sensor.
#define CUSTOM_SETTINGS
#define INCLUDE_FOURSQUARE_SHIELD

#include <OneSheeld.h>

const int echoPin1 = 2;
const int trigPin1 = 4;


void setup() {
  OneSheeld.begin();
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
}

void loop()
{
 long duration1, distance1;

  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin1, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin1, LOW);

  duration1 = pulseIn(echoPin1, HIGH);
  // convert the time into a distance1
  distance1 = duration1 / 29 / 2;

  if(distance1 <= 5 && distance1 > 0)
  {
    /* Check-in at Integreight. */
    Foursquare.checkIn("511759f2e4b0b0ae6ed91067","Back to work!");
  }
  OneSheeld.delay(2000);
}

Credits

Guest

Posted by Amr Saleh

Comments