millis

94 views
Skip to first unread message

Vasant Phadke

unread,
Dec 21, 2011, 11:53:07 PM12/21/11
to Pinguino
i recently started working on pinguino and wanted to make a snooze
timer for my son who wants to stay awake while studying. he should
press a button within a specified time or else the buzzer will sound
and awaken him

i needed to resert the millis count for this sothat every time the
button is pressed the cycle starts over again

i searched and found the _millis(0) post

i copy pasted the whole code as a trial but it wont compile giving
error

i am using beta 9.05 and 18F2550

thanks in advance for helping

vasant phadke

jp mandon

unread,
Dec 22, 2011, 3:19:27 AM12/22/11
to pingui...@googlegroups.com
Hi

_millis is an internal variable used to count time. You can reset it using:
_millis=0;

I hope your son will stay awake with this !!

Jean-Pierre

2011/12/22 Vasant Phadke <nasi...@gmail.com>

vasant phadke

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes Pinguino.
Pour envoyer un message à ce groupe, adressez un e-mail à pingui...@googlegroups.com.
Pour vous désabonner de ce groupe, envoyez un e-mail à l'adresse pinguinocard...@googlegroups.com.
Pour plus d'options, consultez la page de ce groupe : http://groups.google.com/group/pinguinocard?hl=fr


Vasant Phadke

unread,
Dec 22, 2011, 4:12:25 AM12/22/11
to Pinguino
i tried that by copying a code of millis reset given elsewhere in the
group posts

but it wont compile giving error

i dont know why . i am using pinguino beta 9-05 or shall i use another
version

thanks again for a quick one

vasant

On Dec 22, 1:19 pm, jp mandon <jp.man...@gmail.com> wrote:
> Hi
>
> _millis is an internal variable used to count time. You can reset it using:
> _millis=0;
>
> I hope your son will stay awake with this !!
>
> Jean-Pierre
>
> 2011/12/22 Vasant Phadke <nasik2...@gmail.com>

Benoit Espinola

unread,
Dec 22, 2011, 4:22:50 AM12/22/11
to pingui...@googlegroups.com
Replace _millis(0); with _millis=0;

Did you try this?

Sent from my iPhone

Benoit Espinola

unread,
Dec 22, 2011, 4:24:21 AM12/22/11
to pingui...@googlegroups.com
If you post the source code we can also help you in a more effective way...

Best regards,

Benoit

On 22 déc. 2011, at 10:12, Vasant Phadke <nasi...@gmail.com> wrote:

Vasant Phadke

unread,
Dec 22, 2011, 5:59:00 AM12/22/11
to Pinguino
void setup()
{
pinMode(0,OUTPUT);
digitalWrite(0,LOW);
}

void loop()
{
if (millis()>1000) digitalWrite(0,HIGH); // light the led after 1
second

if (millis()>2000) _millis=0; // reset the millis() counter after 2
seconds
}

this is the code from the wiki--functions--millis

i tried _millis0; and _millis(0); both

same compilation error-------error 20: Undefined identifier '_Millis'
thanks again for a quick reply

regards
vasant


On Dec 22, 2:24 pm, Benoit Espinola <benoitespin...@gmail.com> wrote:
> If you post the source code we can also help you in a more effective way...
>
> Best regards,
>
> Benoit
>

jp mandon

unread,
Dec 22, 2011, 6:49:49 AM12/22/11
to pingui...@googlegroups.com
remove the comment '// reset the millis() counter after 2' and it will be OK. This is a bug of the 9-05 release.

JP

2011/12/22 Vasant Phadke <nasi...@gmail.com>

Vasant Phadke

unread,
Dec 22, 2011, 8:46:38 AM12/22/11
to pingui...@googlegroups.com
Thanks everybody for the response i will try it tomorrow and revert
back thanks once again
Vasant

--
Sent from my mobile device

Benoit Espinola

unread,
Dec 22, 2011, 12:06:09 PM12/22/11
to pingui...@googlegroups.com
You reset the millis count but you don't seem to put the Pin 0 state to LOW...

Regards,

Benoit

Vasant Phadke

unread,
Dec 22, 2011, 10:53:45 PM12/22/11
to Pinguino
dear jp
i tried ,first thing in the morning,by removing the comment
sorry but still the same error
vasant phadke


On Dec 22, 6:46 pm, Vasant Phadke <nasik2...@gmail.com> wrote:
> Thanks everybody for the response i will try it tomorrow and revert
> back thanks once again
> Vasant
>
> On 12/22/11, jp mandon <jp.man...@gmail.com> wrote:
>
>
>
>
>
>
>
>
>
> > remove the comment '// reset the millis() counter after 2' and it will be
> > OK. This is a bug of the 9-05 release.
>
> > JP
>
> > 2011/12/22 Vasant Phadke <nasik2...@gmail.com>

Benoit Espinola

unread,
Dec 23, 2011, 5:10:48 AM12/23/11
to pingui...@googlegroups.com
void setup()
{
pinMode(0,OUTPUT);
digitalWrite(0,LOW);
}

void loop()
{
if (millis() > 1000) digitalWrite(0,HIGH);

if (millis() > 2000){
_millis = 0;
digitalWrite(0,LOW);
}
}

Try to copy and paste this code, I removed all the comments and added a space in between the operators and conditionals and added the digitalWrite low to turn off the LED

(I have no computer with me right now so I cannot test the source code but try this anyway)

Vasant Phadke

unread,
Dec 23, 2011, 6:30:25 AM12/23/11
to Pinguino
thanka benoit that has taken care of my problem

thanks again

vasant

On Dec 23, 3:10 pm, Benoit Espinola <benoitespin...@gmail.com> wrote:
> void setup()
> {
> pinMode(0,OUTPUT);
> digitalWrite(0,LOW);
>
> }
>
> void loop()
> {
> if (millis() > 1000) digitalWrite(0,HIGH);
>
> if (millis() > 2000){
>  _millis = 0;
> digitalWrite(0,LOW);
>
> }
> }
>
> Try to copy and paste this code, I removed all the comments and added a space in between the operators and conditionals and added the digitalWrite low to turn off the LED
>
> (I have no computer with me right now so I cannot test the source code but try this anyway)
>
Reply all
Reply to author
Forward
0 new messages