Pages: [1]   Go Down
Author Topic: AS BEGINNER  (Read 414 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have some couple of minor problems, I just don't know how to solve them.
(Objectif 1: Use a RES variable in math equation )
On first image of Arduino, I can't figure out how to put ",2" character to get two decimals on Serial monitor.

(Objectif 2: Test measurement on D2 using boolean)  
On second image, I can't understand an error in my void setup  

Thanks a lot. Sorry for french comments.    



* Screen shot 2012-11-19 at 6.09.47 AM.png (30.04 KB, 730x634 - viewed 18 times.)

* Screen shot 2012-11-19 at 6.13.43 AM.png (12.25 KB, 549x423 - viewed 15 times.)
« Last Edit: November 19, 2012, 06:20:23 am by Nick2012Future » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46009
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First, posting pictures of your code is nowhere near as good as posting your real code. We can't cut and paste mistakes from your pictures.

Also, once we go to reply mode, the pictures go away.

Quote
I can't figure out how to put ",2" character to get two decimals on Serial monitor.
It goes INSIDE the parentheses. It's an optional argument. It's also the default. Of course, it only applies to printing floats or doubles (which are really floats, too). Printing an int to two decimal places makes no sense.

Quote
On second image, I can't understand an error in my void setup
Your code is full of errors. Some time spent with the reference page would be much more beneficial than my pointing them all out.

Logged

UK
Offline Offline
Shannon Member
****
Karma: 183
Posts: 11148
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are several problems.

The ',2' arguments you're trying to pass to Serial.print need to be inside the brackets, as PaulS pointed out.

In your case the numbers you're printing are integers (whole numbers) so for example 5/2 is equal to 2.5 but when you use integer arithmetic the '.5' is lost and the answer is 2. If you're printing integers then the second argument isn't required anyway.

In your print statements you are printing values like this:
Code:
Serial.print(RES = RES/2);

That has two effects: it prints the value of  RES/2, and it also assigned that value back to RES so RES is no longer equal to five - this would affect the results of all the subsequent calculations. If you only want to print the value of RES/2 without changing the value of RES in the process, then you can do it like this:

Code:
Serial.print(RES/2);
Logged

I only provide help via the forum - please do not contact me for private consultancy.

UK
Offline Offline
Faraday Member
**
Karma: 92
Posts: 3969
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sorry to say this, but you really don't have much of a clue, do you?  I think there are more incorrect lines that there are correct ones.

You need to go back to absolute basics.  Before you do ANY programming, you need to understand the BASIC SYNTAX of the language.

You should read and thoroughly understand this PDF file: www.cs.mcgill.ca/~adenau/teaching/cs206/lecture10.pdf

It details the basic syntax of the C language, and once you know that, you will quickly see where all your errors are.
Logged

Why not visit my eBay shop? http://stores.ebay.co.uk/Majenko-Technologies
Replacement for the Arduino IDE: UECIDE - Proper serial terminal, graphing facilities, plugins, overhauled internals.
Java isn't bad in itself, but it has enabled morons to write programs.

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 238
Posts: 24319
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Sorry for french comments.
http://arduino.cc/forum/index.php/board,33.0.html
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok! I think I got it finally, I have just to mention float to initiate my variables and then I can select number of decimals.

Thanks a lot for tutorials!!   
Logged

Pages: [1]   Go Up
Jump to: