Ardunio based height measurement project

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Ardunio based height measurement project

Postby uzzal » Tue Aug 08, 2017 1:10 pm

I have tried to do the project named "Ardunio based height measurement project" according to the directives of the Cytron. I have included the new NEWPING library and run the given code in the site, but the following error is coming. How can I overcome from the error. I am using the code:
CODE: SELECT_ALL_CODE
#include <NewPing.h>
#include <LiquidCrystal.h>
#define TRIGGER_PIN 13
#define ECHO_PIN 12
#define MAX_DISTANCE 500
int val = 0;
int val2 ;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
LiquidCrystal lcd(6,7,8,9,10,11);
void setup() {
lcd.begin(16,2);
pinMode(5,INPUT);
}

void loop() {
lcd.home();
unsigned int uS = sonar.ping();
if(digitalRead(5) == HIGH & val <= 0){
plus();
val2 = uS/ US_ROUNDTRIP_CM ;
}

if(digitalRead(5) == LOW & val <= 0){ lcd.print("Waiting for"); lcd.setCursor(0,1); lcd.print("Calibration"); } if(digitalRead(5) == LOW & val >= 1){
lcd.print(val2 – uS / US_ROUNDTRIP_CM);
lcd.print("cm");
delay(100);

}
if(digitalRead(5) == HIGH & val >= 1){
lcd.print(val2 -uS / US_ROUNDTRIP_CM);
lcd.print("cm");
delay(100);

}
delay(100);
lcd.clear();
}
void plus(){
val = val + 1;
}

The following error is coming after compilation:
CODE: SELECT_ALL_CODE
height:24: error: stray '\342' in program
 lcd.print(val2 – uS / US_ROUNDTRIP_CM);
 ^
height:24: error: stray '\200' in program
height:24: error: stray '\223' in program
/home/uzzal/Arduino/libraries/height/height.ino: In function 'void loop()':
height:24: error: expected ')' before 'uS'
 lcd.print(val2 – uS / US_ROUNDTRIP_CM);
                    ^
exit status 1
stray '\342' in program
uzzal
Greenhorn
 
Posts: 2
Joined: Mon Aug 07, 2017 6:10 pm

Re: Ardunio based height measurement project

Postby Idris » Wed Aug 09, 2017 6:06 pm

Hi uzzal,

Could I know where do you get the code? Mind to share the link?
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: Ardunio based height measurement project

Postby uzzal » Wed Aug 09, 2017 6:15 pm

Yesterday, I am able to solve the code problem. Now Code compilation is done. I have uploaded the code to the Ardunio UNo but the results are not showing in the LCD.
There was a instruction to change the potentiometer value. I have tried to change the value of the potentiometer but still the output is not shown in the LCD.
All the cables I have checked.

So what would be the solution to get the height measurement data on LCD?
Thanks for your queries. I have made all the arrangements as shown in the link below:

The link is : http://tutorial.cytron.com.my/2015/04/2 ... arduino-2/
uzzal
Greenhorn
 
Posts: 2
Joined: Mon Aug 07, 2017 6:10 pm

Re: Ardunio based height measurement project

Postby ZaM » Thu Aug 10, 2017 9:03 am

Hi, because you dont attach any picture or brief more detail, then i just want to make sure, do you see any character on your LCD? for example "Waiting for Calibration" or BLACK DOT LCD.
This is the list of possible root cause.
1. if you can see waiting for calibration then you connection for LCD is OK.
2. if you just see black Dot, then check you contrast (potentiometer) connection
3. i assume you not change the code, then the problem now only with you connection. (lcd(6,7,8,9,10,11);)
4. To test LCD functionality, goto Arduino IDE>File tab>Example>LiquidCrystal>HelloWorld. Then replace pin defination line (LiquidCrystal lcd(12, 11, 5, 4, 3, 2);) with "LiquidCrystal lcd(6,7,8,9,10,11);", you lcd should display HelloWorld.
5. if step 4 success, please show you connection for Sonar sensor here. Double check the connection.
ZaM
Moderator
 
Posts: 78
Joined: Tue Nov 23, 2010 4:16 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 13 guests

cron