I want my HC-SR04 to display its reading on a 16x2 LCD
This is the code:
/*
Coded By: http://electronicsproject.org
*/
#define trigPin 7
#define echoPin 8
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
lcd.begin(16, 2);
lcd.print("electronics");
lcd.setCursor(0, 1);
lcd.print("project.org");
delay(2000);
lcd.clear();
lcd.print("Welcome To");
lcd.setCursor(0, 1);
lcd.print("Distnance Meter");
delay(2000);
lcd.clear();
lcd.print("Designed by:");
lcd.setCursor(0, 1);
lcd.print("ElectronicsProject");
}
void loop() {
int timetaken, dist;
lcd.clear();
lcd.print("Distance in CM:");
digitalWrite(trigPin, HIGH);
delayMicroseconds(1000);
digitalWrite(trigPin, LOW);
timetaken = pulseIn(echoPin, HIGH);
dist = (timetaken/2) * 0.034049 ;
if (dist >= 300 || dist <= 0){
lcd.setCursor(0, 1);
lcd.print("Out Of Range");
}
else
{
lcd.setCursor(0, 1);
lcd.print(dist);
}
delay(500);
}
This is the error message:
Arduino: 1.6.4 (Windows 7), Board: "Arduino Uno"
sketch_jan04a:12: error: stray '' in program
sketch_jan04a:12: error: stray '' in program
sketch_jan04a:14: error: stray '' in program
sketch_jan04a:14: error: stray '' in program
sketch_jan04a:17: error: stray '' in program
sketch_jan04a:17: error: stray '' in program
sketch_jan04a:19: error: stray '' in program
sketch_jan04a:19: error: stray '' in program
sketch_jan04a:22: error: stray '' in program
sketch_jan04a:22: error: stray '' in program
sketch_jan04a:24: error: stray '' in program
sketch_jan04a:24: error: stray '' in program
sketch_jan04a:29: error: stray '' in program
sketch_jan04a:29: error: stray '' in program
sketch_jan04a:37: error: stray '' in program
sketch_jan04a:37: error: stray '' in program
sketch_jan04a.ino: In function 'void setup()':
sketch_jan04a:12: error: 'u201celectronics' was not declared in this scope
sketch_jan04a:14: error: 'u201cproject' was not declared in this scope
sketch_jan04a:17: error: 'u201cWelcome' was not declared in this scope
sketch_jan04a:19: error: 'u201cDistnance' was not declared in this scope
sketch_jan04a:22: error: 'u201cDesigned' was not declared in this scope
sketch_jan04a:24: error: 'u201cElectronicsProject' was not declared in this scope
sketch_jan04a.ino: In function 'void loop()':
sketch_jan04a:29: error: 'u201cDistance' was not declared in this scope
sketch_jan04a:37: error: 'u201cOut' was not declared in this scope
stray '' in program
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
http://electronicsproject.org/arduino-based-distance-sensor/
Please Help....