Fwd: arduino ultrasonic ప్రోగ్రాం
---------- Forwarded message ---------
From: pingili vikram kumar <vikramkumar.volunteer@gmail.com>
Date: Sun, Jul 31, 2022, 15:04
Subject: arduino ultrasonic ప్రోగ్రాం
To: sudheer nuni <sudheer.nuni@gmail.com>
From: pingili vikram kumar <vikramkumar.volunteer@gmail.com>
Date: Sun, Jul 31, 2022, 15:04
Subject: arduino ultrasonic ప్రోగ్రాం
To: sudheer nuni <sudheer.nuni@gmail.com>
// modified by vikram bhayya
const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 6; // Echo Pin of Ultrasonic Sensor
void setup() {
Serial.begin(9600); // Starting Serial Terminal
pinMode(7, OUTPUT);
pinMode(6, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
long duration, cm; //inches,
digitalWrite(7, LOW);
delayMicroseconds(2);
digitalWrite(7, HIGH);
delayMicroseconds(10);
digitalWrite(7, LOW);
duration = pulseIn(6, HIGH);
//inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
if (cm<15)
digitalWrite(13,HIGH);
else
digitalWrite(13,LOW);
/*Serial.print(inches);
Serial.print("in, ");*/
Serial.print(cm);
Serial.println("cm");
// Serial.println();
delay(1000);
}
/*long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2;
}*/
long microsecondsToCentimeters(long p) {
return p / 29 / 2;
}
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.