New Homepage Forums Special Shields Getting Current Time

This topic contains 5 replies, has 2 voices, and was last updated by avatar Eslam Ali 2 years, 11 months ago. This post has been viewed 699 times

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10634
    avatarbfulford
    Participant

    Hi, I used the following code to test my currentTime function and got some strange results. When I switch to Operating Mode, currentTime is in seconds up until the first minute and then in minutes + seconds in seconds. I assume that if I waited an hour it would become hours + minutes + seconds in seconds (the desired result). If I press the reset button on the Uno, it prints a negative number. What’s going on?

     

    #10638
    avatarEslam Ali
    Participant

    Hi bfulford,

    Yeah it’s about the data type you declared for your variable .. you declared an signed integer which can hold values from (-32,768 to 32,767 ) even if you declared the variable with unsigned integer it can’t hold value more than (65,535) so values will be greater than the highest unsigned integer value whenever it comes late “night” .. So in case you will have to declare an unsigned long variable to hold your data as unsigned long can hold values from (0 to 4294967295).

    check the code below:

    Wish my reply helped you đŸ˜‰ .

     

     

    #10639
    avatarbfulford
    Participant

    Hi Eslam,

    Your version worked perfectly for a while, but now I just get currentTime = 0 printed every second. Pressing the Arduino reset button makes no difference, nor does pressing the 1Sheeld reset button, and even restarting the phone made no difference. Any thoughts?

    #10644
    avatarEslam Ali
    Participant

    Hi bfulford,

    That’s weird … i managed to test the example for the whole day ” 24 hours” and it worked perfectly ..! can you please explain in details what happened ?

    Thanks..

    #10649
    avatarbfulford
    Participant

    Well, I don’t know what happened. It is working perfectly now. Is it possible that the device can be connected but not communicating? If it happens again I’ll take note of the tx/rx leds to see if something is amiss. Thanks for help.

    #10650
    avatarEslam Ali
    Participant

    Hi bfulford,

    Happy to hear that everything is working perfectly đŸ™‚ . but for your question

    Is it possible that the device can be connected but not communicating?

    Ammmmm yeah actually it rarely occurs .. But maybe you faced another situation cuz whenever the Tx/Rx leds keeps flashing means that the communication is all good.. maybe a couple of frames where lost while communicating. Please let us know if anything similar happened.

    Thanks

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.