#include <LiquidCrystal.h>
int trigPin = 13; //sensor's trigger pin connected to pin 13
int echoPin = 7; //sensor's echo pin connected to pin 11
float pingTime; //time for the ping to hit the target and back
float ss; //we will calculate the speed of sound
float td = 13; //target distance.
void setup() {
// put your setup code here, to run once:
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Serial.begin(9600);
pinMode(trigPin,OUTPUT); //TRIG AS OUTPUT
pinMode(echoPin,INPUT); //EHO AS AN INPUT
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.println(ss);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigPin,LOW); //set trig pin low.
delayMicroseconds(2000);
digitalWrite(trigPin,HIGH);
delayMicroseconds(100);
digitalWrite(trigPin,LOW);
pingTime = pulseIn(echoPin,HIGH); //measure ping time traveltime in microseconds.
ss= 2*td / pingTime; //gives us speed in inches per microseconds.
ss=ss/63360*1000000*3600; //gives us speed in miles per hour.
Serial.print("The speed of sound is ");
Serial.print(ss);
Serial.println(" miles per hour");
// Turn off the blinking cursor:
lcd.noBlink();
delay(3000);
// Turn on the blinking cursor:
lcd.blink(0);
delay(3000);
}
int trigPin = 13; //sensor's trigger pin connected to pin 13 int echoPin = 7; //sensor's echo pin connected to pin 11 float pingTime; //time for the ping to hit the target and back float ss; //we will calculate the speed of sound float td = 13; //target distance.
void setup() { // put your setup code here, to run once:
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Serial.begin(9600); pinMode(trigPin,OUTPUT); //TRIG AS OUTPUT pinMode(echoPin,INPUT); //EHO AS AN INPUT
// set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.println(ss);
}
void loop() { // put your main code here, to run repeatedly:
digitalWrite(trigPin,LOW); //set trig pin low. delayMicroseconds(2000); digitalWrite(trigPin,HIGH); delayMicroseconds(100); digitalWrite(trigPin,LOW); pingTime = pulseIn(echoPin,HIGH); //measure ping time traveltime in microseconds. ss= 2td / pingTime; //gives us speed in inches per microseconds. ss=ss/633601000000*3600; //gives us speed in miles per hour. Serial.print("The speed of sound is "); Serial.print(ss); Serial.println(" miles per hour");
// Turn off the blinking cursor: lcd.noBlink(); delay(3000); // Turn on the blinking cursor: lcd.blink(0); delay(3000);
}
#include <LiquidCrystal.h>
int trigPin = 13; //sensor's trigger pin connected to pin 13 int echoPin = 7; //sensor's echo pin connected to pin 11 float pingTime; //time for the ping to hit the target and back float ss; //we will calculate the speed of sound float td = 13; //target distance.
void setup() { // put your setup code here, to run once:
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Serial.begin(9600); pinMode(trigPin,OUTPUT); //TRIG AS OUTPUT pinMode(echoPin,INPUT); //EHO AS AN INPUT
// set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.println(ss);
}
void loop() { // put your main code here, to run repeatedly:
digitalWrite(trigPin,LOW); //set trig pin low. delayMicroseconds(2000); digitalWrite(trigPin,HIGH); delayMicroseconds(100); digitalWrite(trigPin,LOW); pingTime = pulseIn(echoPin,HIGH); //measure ping time traveltime in microseconds. ss= 2td / pingTime; //gives us speed in inches per microseconds. ss=ss/633601000000*3600; //gives us speed in miles per hour. Serial.print("The speed of sound is "); Serial.print(ss); Serial.println(" miles per hour");
// Turn off the blinking cursor: lcd.noBlink(); delay(3000); // Turn on the blinking cursor: lcd.blink(0); delay(3000);
}
#include <LiquidCrystal.h>
int trigPin = 13; //sensor's trigger pin connected to pin 13
int echoPin = 7; //sensor's echo pin connected to pin 11
float pingTime; //time for the ping to hit the target and back
float ss; //we will calculate the speed of sound
float td = 13; //target distance.
void setup() {
// put your setup code here, to run once:
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Serial.begin(9600);
pinMode(trigPin,OUTPUT); //TRIG AS OUTPUT
pinMode(echoPin,INPUT); //EHO AS AN INPUT
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.println(ss);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigPin,LOW); //set trig pin low.
delayMicroseconds(2000);
digitalWrite(trigPin,HIGH);
delayMicroseconds(100);
digitalWrite(trigPin,LOW);
pingTime = pulseIn(echoPin,HIGH); //measure ping time traveltime in microseconds.
ss= 2*td / pingTime; //gives us speed in inches per microseconds.
ss=ss/63360*1000000*3600; //gives us speed in miles per hour.
Serial.print("The speed of sound is ");
Serial.print(ss);
Serial.println(" miles per hour");
// Turn off the blinking cursor:
lcd.noBlink();
delay(3000);
// Turn on the blinking cursor:
lcd.blink(0);
delay(3000);
}
I keep on getting a stray '302円' in program error.How do I fix it.This is in arduino uno
#include <LiquidCrystal.h>
int trigPin = 13; //sensor's trigger pin connected to pin 13 int echoPin = 7; //sensor's echo pin connected to pin 11 float pingTime; //time for the ping to hit the target and back float ss; //we will calculate the speed of sound float td = 13; //target distance.
void setup() { // put your setup code here, to run once:
// initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Serial.begin(9600); pinMode(trigPin,OUTPUT); //TRIG AS OUTPUT pinMode(echoPin,INPUT); //EHO AS AN INPUT
// set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. lcd.println(ss);
}
void loop() { // put your main code here, to run repeatedly:
digitalWrite(trigPin,LOW); //set trig pin low. delayMicroseconds(2000); digitalWrite(trigPin,HIGH); delayMicroseconds(100); digitalWrite(trigPin,LOW); pingTime = pulseIn(echoPin,HIGH); //measure ping time traveltime in microseconds. ss= 2td / pingTime; //gives us speed in inches per microseconds. ss=ss/633601000000*3600; //gives us speed in miles per hour. Serial.print("The speed of sound is "); Serial.print(ss); Serial.println(" miles per hour");
// Turn off the blinking cursor: lcd.noBlink(); delay(3000); // Turn on the blinking cursor: lcd.blink(0); delay(3000);
}