Customers who bought this product also commonly purchased the following combination of items.
- This Item: LCD KEYPAD Shield-Serial
-
2pcs Screwshield Expansion Board for Arduino
-
12V-2A DC Adapter
-
RDL UNO ATMEGA328 Development Board 3 in 1=Uno+Memory Shield+Xbee Footprint
-
-
Out of stock
-
-
-
0voteA:
Dear Mr.Vinod
Please find the code below
int TrigPin = 5;
int EchoPin = 6;
void setup()
{
Serial.begin(9600);
pinMode(TrigPin,OUTPUT);
pinMode(EchoPin,INPUT);
}
void loop()
{
float distance,duration;
float cd;
digitalWrite(TrigPin,HIGH);//TrigPin prepare high of more than 10us
delayMicroseconds(11);
digitalWrite(TrigPin,LOW);duration = pulseIn(EchoPin, HIGH);//EchoPin received high start counting until the receiver to the low,return to the count valu
duration =duration/29/2;//Calculating the distance cm
// The speed of s ound is 340 m/s or 29 microseconds per centimeter.
// cd=duration/10;
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("-DISTANCE-");
Serial.write(byte(0XC0));
Serial.print(duration);//Serial display distance
Serial.print("cm");
delay(1000);
}int TrigPin = 5;
int EchoPin = 6;
void setup()
{
Serial.begin(9600);
pinMode(TrigPin,OUTPUT);
pinMode(EchoPin,INPUT);
}
void loop()
{
float distance,duration;
float cd;
digitalWrite(TrigPin,HIGH);//TrigPin prepare high of more than 10us
delayMicroseconds(11);
digitalWrite(TrigPin,LOW);duration = pulseIn(EchoPin, HIGH);//EchoPin received high start counting until the receiver to the low,return to the count valu
duration =duration/29/2;//Calculating the distance cm
// The speed of s ound is 340 m/s or 29 microseconds per centimeter.
// cd=duration/10;
Serial.write(byte(0X01));
Serial.write(byte(0X80));
Serial.print("-DISTANCE-");
Serial.write(byte(0XC0));
Serial.print(duration);//Serial display distance
Serial.print("cm");
delay(1000);
}Posted byon Friday, 6 March 2015