Obstacle Avoidance Sensor Module

  • Obstacle Avoidance Sensor Module
Below the corresponding code:

//Author: Danny van den Brande. BlueCore Tech. Arduinosensors.nl
//This is an example code on how to use the obstacle avoidance sensor KY-032
//This sensor works the same as warning sensors in cars. Used in many robot projects.
int Buzzer = 3;
int AvoidancePin = 4; // define the obstacle avoidance sensor interface
int RedLed = 5 ;
int GreenLed = 6 ;
int val ;// Value High or LOW. 

// here i set up the tones, you can change them @ void loop.
int tones[] = {261, 277, 293, 311, 329, 349, 369, 392, 415, 440, 466, 493, 523 ,554};
//              1    2    3    4    5    6    7    8    9    10   11   12   13   14
// You can add more tones but i added 14. Just fill in what tone you would like to use, @ void loop you see " tone(Buzzer, tones[12]); " below,  digitalWrite(Buzzer, HIGH);
// here you can change the tones by filling in a number between 1 and 14

void setup ()
{
  Serial.begin (9600);
  pinMode (RedLed, OUTPUT) ;
  pinMode (GreenLed, OUTPUT) ; 
  pinMode (Buzzer, OUTPUT) ;
  pinMode (AvoidancePin, INPUT) ;// define the obstacle avoidance sensor output interface
}
void loop ()
{
  val = digitalRead (AvoidancePin) ;// Reading from the AvoidancePin
  if (val == HIGH) 
  {
    digitalWrite (RedLed, LOW);
    digitalWrite (GreenLed, HIGH);
    digitalWrite (Buzzer, LOW);
    noTone(Buzzer);
    delay(100);
  }
  else
  {
    digitalWrite (RedLed, HIGH);
    digitalWrite (GreenLed, LOW);
    digitalWrite (Buzzer, HIGH);
    tone(Buzzer, tones[6]);//You can change the tone choosing from 1 to 14.
    delay(100);
    
  }
}
Specifications
Power consumption: 3v-5V
Operating temperature: -10 ℃ - +50 ℃
Detection distance: 2-40cm
Effective angle: 35 °

Write a review

Please login or register to review

Obstacle Avoidance Sensor Module

  • Webwinkel Keurmerk en klantebeoordelingen

  • 14 dagen bedenktijd 
  • Verzendkosten voor eigen rekening
  • Product Code: KY-032 EASM101700
  • Availability: 10
  • 2.49€

  • Ex Tax: 2.06€

Similar Products

Tilt Switch Sensor Module

Tilt Switch Sensor Module

Below you can see the corresponding code: An example project for the Tilt Switch/* Author: Danny v..

2.29€ Ex Tax: 1.89€

1 Channel Relay Module

1 Channel Relay Module

Below you can see the corresponding code: An example of a project for the ky-019/* Author: Danny v..

2.49€ Ex Tax: 2.06€

Digital Temperature Sensor

Digital Temperature Sensor

Below the corresponding code:#include <math.h>  int sensorPin = A5; // select the input ..

2.36€ Ex Tax: 1.95€

Temperature Sensor Module

Temperature Sensor Module

Download the required libraries below:DallasTemperature-Library.zipLCD5110_Graph-Library.zipBelow yo..

2.99€ Ex Tax: 2.47€