Skip to content

Proximity Sensor

![[Pasted image 20230521230251.png|300]]

int buzzer = 11;
int sensor = 4;
int led = 13;
void setup() 
{
  Serial.begin(9200);

  pinMode(buzzer, OUTPUT);
  pinMode(sensor, INPUT);
  pinMode(led, OUTPUT);

  digitalWrite(buzzer,LOW);
  digitalWrite(sensor,LOW);
  digitalWrite(led,LOW);
}

void loop() 
{

  if(digitalRead(sensor) == HIGH){
    Serial.println("SUCCESS");
    digitalWrite(buzzer, LOW);
  }else{
    Serial.println("FAIL");
    digitalWrite(buzzer, HIGH);
  }
}