Why my light meter's values are blank on Arduino Serial Monitor?
up vote
0
down vote
favorite
I tried to represent the values of TSL 2591 Adafruit light sensor on my Arduino Serial Monitor, but for some reason, I could not do that. The Arduino Serial Monitor just enters some blank values and scrolls down.
Here is the code:
uint16_t x = tsl.getLuminosity(TSL2591_VISIBLE);
y = float(tsl.getLuminosity(TSL2591_VISIBLE));
z = (y, DEC);
Serial.write((byte)z);
x
, y
, and z
are floats initially.
serial sensors
migrated from stackoverflow.com Nov 15 at 13:55
This question came from our site for professional and enthusiast programmers.
add a comment |
up vote
0
down vote
favorite
I tried to represent the values of TSL 2591 Adafruit light sensor on my Arduino Serial Monitor, but for some reason, I could not do that. The Arduino Serial Monitor just enters some blank values and scrolls down.
Here is the code:
uint16_t x = tsl.getLuminosity(TSL2591_VISIBLE);
y = float(tsl.getLuminosity(TSL2591_VISIBLE));
z = (y, DEC);
Serial.write((byte)z);
x
, y
, and z
are floats initially.
serial sensors
migrated from stackoverflow.com Nov 15 at 13:55
This question came from our site for professional and enthusiast programmers.
Did you enabled the serial communication on arduino by usingSerial.begin(9600)
?
– svtag
Nov 15 at 9:22
1
What'sz = (y, DEC);
supposed to do?
– Gerben
Nov 15 at 16:18
Yes, I enabled it. What if I change 9600 to another value? @svtag
– Асмир Абдимажитов
Nov 16 at 9:46
I think it converts the values to decimals @Gerben
– Асмир Абдимажитов
Nov 16 at 9:47
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I tried to represent the values of TSL 2591 Adafruit light sensor on my Arduino Serial Monitor, but for some reason, I could not do that. The Arduino Serial Monitor just enters some blank values and scrolls down.
Here is the code:
uint16_t x = tsl.getLuminosity(TSL2591_VISIBLE);
y = float(tsl.getLuminosity(TSL2591_VISIBLE));
z = (y, DEC);
Serial.write((byte)z);
x
, y
, and z
are floats initially.
serial sensors
I tried to represent the values of TSL 2591 Adafruit light sensor on my Arduino Serial Monitor, but for some reason, I could not do that. The Arduino Serial Monitor just enters some blank values and scrolls down.
Here is the code:
uint16_t x = tsl.getLuminosity(TSL2591_VISIBLE);
y = float(tsl.getLuminosity(TSL2591_VISIBLE));
z = (y, DEC);
Serial.write((byte)z);
x
, y
, and z
are floats initially.
serial sensors
serial sensors
edited Nov 26 at 14:52
gre_gor
1,51741224
1,51741224
asked Nov 15 at 7:04
Асмир Абдимажитов
31
31
migrated from stackoverflow.com Nov 15 at 13:55
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Nov 15 at 13:55
This question came from our site for professional and enthusiast programmers.
Did you enabled the serial communication on arduino by usingSerial.begin(9600)
?
– svtag
Nov 15 at 9:22
1
What'sz = (y, DEC);
supposed to do?
– Gerben
Nov 15 at 16:18
Yes, I enabled it. What if I change 9600 to another value? @svtag
– Асмир Абдимажитов
Nov 16 at 9:46
I think it converts the values to decimals @Gerben
– Асмир Абдимажитов
Nov 16 at 9:47
add a comment |
Did you enabled the serial communication on arduino by usingSerial.begin(9600)
?
– svtag
Nov 15 at 9:22
1
What'sz = (y, DEC);
supposed to do?
– Gerben
Nov 15 at 16:18
Yes, I enabled it. What if I change 9600 to another value? @svtag
– Асмир Абдимажитов
Nov 16 at 9:46
I think it converts the values to decimals @Gerben
– Асмир Абдимажитов
Nov 16 at 9:47
Did you enabled the serial communication on arduino by using
Serial.begin(9600)
?– svtag
Nov 15 at 9:22
Did you enabled the serial communication on arduino by using
Serial.begin(9600)
?– svtag
Nov 15 at 9:22
1
1
What's
z = (y, DEC);
supposed to do?– Gerben
Nov 15 at 16:18
What's
z = (y, DEC);
supposed to do?– Gerben
Nov 15 at 16:18
Yes, I enabled it. What if I change 9600 to another value? @svtag
– Асмир Абдимажитов
Nov 16 at 9:46
Yes, I enabled it. What if I change 9600 to another value? @svtag
– Асмир Абдимажитов
Nov 16 at 9:46
I think it converts the values to decimals @Gerben
– Асмир Абдимажитов
Nov 16 at 9:47
I think it converts the values to decimals @Gerben
– Асмир Абдимажитов
Nov 16 at 9:47
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
Use Serial.println(x); to print a number as text. Function write() sends the raw byte and Serial Monitor shows the character with that ASCII code, which is not valid or a not visible control character.
For the z = (y, DEC);
from Wikipedia:
In the C and C++ programming languages, the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
so z
is always 10 (value of constant DEC), which is ASCII code for the new line character
Comments are not for extended discussion; this conversation has been moved to chat.
– Majenko♦
Nov 16 at 18:48
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
Use Serial.println(x); to print a number as text. Function write() sends the raw byte and Serial Monitor shows the character with that ASCII code, which is not valid or a not visible control character.
For the z = (y, DEC);
from Wikipedia:
In the C and C++ programming languages, the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
so z
is always 10 (value of constant DEC), which is ASCII code for the new line character
Comments are not for extended discussion; this conversation has been moved to chat.
– Majenko♦
Nov 16 at 18:48
add a comment |
up vote
3
down vote
accepted
Use Serial.println(x); to print a number as text. Function write() sends the raw byte and Serial Monitor shows the character with that ASCII code, which is not valid or a not visible control character.
For the z = (y, DEC);
from Wikipedia:
In the C and C++ programming languages, the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
so z
is always 10 (value of constant DEC), which is ASCII code for the new line character
Comments are not for extended discussion; this conversation has been moved to chat.
– Majenko♦
Nov 16 at 18:48
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
Use Serial.println(x); to print a number as text. Function write() sends the raw byte and Serial Monitor shows the character with that ASCII code, which is not valid or a not visible control character.
For the z = (y, DEC);
from Wikipedia:
In the C and C++ programming languages, the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
so z
is always 10 (value of constant DEC), which is ASCII code for the new line character
Use Serial.println(x); to print a number as text. Function write() sends the raw byte and Serial Monitor shows the character with that ASCII code, which is not valid or a not visible control character.
For the z = (y, DEC);
from Wikipedia:
In the C and C++ programming languages, the comma operator (represented by the token ,) is a binary operator that evaluates its first operand and discards the result, and then evaluates the second operand and returns this value (and type).
so z
is always 10 (value of constant DEC), which is ASCII code for the new line character
edited Nov 16 at 12:22
answered Nov 15 at 10:14
Juraj
6,4002925
6,4002925
Comments are not for extended discussion; this conversation has been moved to chat.
– Majenko♦
Nov 16 at 18:48
add a comment |
Comments are not for extended discussion; this conversation has been moved to chat.
– Majenko♦
Nov 16 at 18:48
Comments are not for extended discussion; this conversation has been moved to chat.
– Majenko♦
Nov 16 at 18:48
Comments are not for extended discussion; this conversation has been moved to chat.
– Majenko♦
Nov 16 at 18:48
add a comment |
Thanks for contributing an answer to Arduino Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2farduino.stackexchange.com%2fquestions%2f57883%2fwhy-my-light-meters-values-are-blank-on-arduino-serial-monitor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Did you enabled the serial communication on arduino by using
Serial.begin(9600)
?– svtag
Nov 15 at 9:22
1
What's
z = (y, DEC);
supposed to do?– Gerben
Nov 15 at 16:18
Yes, I enabled it. What if I change 9600 to another value? @svtag
– Асмир Абдимажитов
Nov 16 at 9:46
I think it converts the values to decimals @Gerben
– Асмир Абдимажитов
Nov 16 at 9:47