Go Down

Topic: Serial print refresh time (Read 2 times) previous topic - next topic

Arrch

Looks good.

As good practice, I would also make the pins and interval constants.

jtw11

#6
May 25, 2012, 06:35 pm Last Edit: May 25, 2012, 06:39 pm by jtw11 Reason: 1

Looks good.

As good practice, I would also make the pins and interval constants.


Sorry - not quite with you. Are you referring to the 'long interval = 20000"? ...and as for the pins?

Arrch


Sorry - not quite with you. Are you referring to the 'long interval = 20000"? ...and as for the pins?

Yes. It's not going to make a difference with your current code, but it's good practice to define them as constants if there is no plan to change them within the code.

jtw11

Hmm - nope, still not got it! :D

Do you mean, as opposed to 'long interval', write 'long const interval'? 'const interval' throws an error at me.

As for pins, what isn't quite best practice?

You'll have to excuse me - before Arduino, I had no experience whatsoever with any C variant.

Arrch


Do you mean, as opposed to 'long interval', write 'long const interval'? 'const interval' throws an error at me.

Code: [Select]

const unsigned long interval =

Quote
As for pins, what isn't quite best practice?

Not sure what you mean by that.

Something like:
Code: [Select]
const int tempPin = 5;
would be best practice. You could also change it to a short, but I don't know which way the compiler handles constant declaration, so I'm not sure if that's necessary.

Go Up