Skip to main content

Android App with Arduino using Bluetooth Sensor

//Code to interface Android App with Arduino using Bluetooth Sensor

int trigPin = 9;
int echoPin = 10;
int led = 13;


void setup()
{
  Serial.begin(9600);
  pinMode(led, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
}

void loop()
{
  long duration, distance;
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration / 2) / 29.1;
  delay(10);

  if ((distance <= 10))
  {
    Serial.print(1);
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
  }
}



MIT App Inventor Block


Follow me @ facebook Instagram linkedin

Comments

Popular posts from this blog

10 Years of Excellence

U Can Project Solution