Why my light meter's values are blank on Arduino Serial Monitor?










0















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.










share|improve this question















migrated from stackoverflow.com Nov 15 '18 at 13:55


This question came from our site for professional and enthusiast programmers.


















  • Did you enabled the serial communication on arduino by using Serial.begin(9600)?

    – svtag
    Nov 15 '18 at 9:22






  • 1





    What's z = (y, DEC); supposed to do?

    – Gerben
    Nov 15 '18 at 16:18











  • Yes, I enabled it. What if I change 9600 to another value? @svtag

    – Асмир Абдимажитов
    Nov 16 '18 at 9:46











  • I think it converts the values to decimals @Gerben

    – Асмир Абдимажитов
    Nov 16 '18 at 9:47
















0















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.










share|improve this question















migrated from stackoverflow.com Nov 15 '18 at 13:55


This question came from our site for professional and enthusiast programmers.


















  • Did you enabled the serial communication on arduino by using Serial.begin(9600)?

    – svtag
    Nov 15 '18 at 9:22






  • 1





    What's z = (y, DEC); supposed to do?

    – Gerben
    Nov 15 '18 at 16:18











  • Yes, I enabled it. What if I change 9600 to another value? @svtag

    – Асмир Абдимажитов
    Nov 16 '18 at 9:46











  • I think it converts the values to decimals @Gerben

    – Асмир Абдимажитов
    Nov 16 '18 at 9:47














0












0








0








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.










share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 14:52









gre_gor

1,51041225




1,51041225










asked Nov 15 '18 at 7:04









Асмир АбдимажитовАсмир Абдимажитов

31




31




migrated from stackoverflow.com Nov 15 '18 at 13:55


This question came from our site for professional and enthusiast programmers.









migrated from stackoverflow.com Nov 15 '18 at 13:55


This question came from our site for professional and enthusiast programmers.














  • Did you enabled the serial communication on arduino by using Serial.begin(9600)?

    – svtag
    Nov 15 '18 at 9:22






  • 1





    What's z = (y, DEC); supposed to do?

    – Gerben
    Nov 15 '18 at 16:18











  • Yes, I enabled it. What if I change 9600 to another value? @svtag

    – Асмир Абдимажитов
    Nov 16 '18 at 9:46











  • I think it converts the values to decimals @Gerben

    – Асмир Абдимажитов
    Nov 16 '18 at 9:47


















  • Did you enabled the serial communication on arduino by using Serial.begin(9600)?

    – svtag
    Nov 15 '18 at 9:22






  • 1





    What's z = (y, DEC); supposed to do?

    – Gerben
    Nov 15 '18 at 16:18











  • Yes, I enabled it. What if I change 9600 to another value? @svtag

    – Асмир Абдимажитов
    Nov 16 '18 at 9:46











  • I think it converts the values to decimals @Gerben

    – Асмир Абдимажитов
    Nov 16 '18 at 9:47

















Did you enabled the serial communication on arduino by using Serial.begin(9600)?

– svtag
Nov 15 '18 at 9:22





Did you enabled the serial communication on arduino by using Serial.begin(9600)?

– svtag
Nov 15 '18 at 9:22




1




1





What's z = (y, DEC); supposed to do?

– Gerben
Nov 15 '18 at 16:18





What's z = (y, DEC); supposed to do?

– Gerben
Nov 15 '18 at 16:18













Yes, I enabled it. What if I change 9600 to another value? @svtag

– Асмир Абдимажитов
Nov 16 '18 at 9:46





Yes, I enabled it. What if I change 9600 to another value? @svtag

– Асмир Абдимажитов
Nov 16 '18 at 9:46













I think it converts the values to decimals @Gerben

– Асмир Абдимажитов
Nov 16 '18 at 9:47






I think it converts the values to decimals @Gerben

– Асмир Абдимажитов
Nov 16 '18 at 9:47











1 Answer
1






active

oldest

votes


















3














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






share|improve this answer

























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Majenko
    Nov 16 '18 at 18:48










Your Answer






StackExchange.ifUsing("editor", function ()
return StackExchange.using("schematics", function ()
StackExchange.schematics.init();
);
, "cicuitlab");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "540"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















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

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














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






share|improve this answer

























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Majenko
    Nov 16 '18 at 18:48















3














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






share|improve this answer

























  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Majenko
    Nov 16 '18 at 18:48













3












3








3







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






share|improve this answer















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







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 16 '18 at 12:22

























answered Nov 15 '18 at 10:14









JurajJuraj

7,5802927




7,5802927












  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Majenko
    Nov 16 '18 at 18:48

















  • Comments are not for extended discussion; this conversation has been moved to chat.

    – Majenko
    Nov 16 '18 at 18:48
















Comments are not for extended discussion; this conversation has been moved to chat.

– Majenko
Nov 16 '18 at 18:48





Comments are not for extended discussion; this conversation has been moved to chat.

– Majenko
Nov 16 '18 at 18:48

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Top Tejano songwriter Luis Silva dead of heart attack at 64

政党

天津地下鉄3号線