Go Down

Topic: Automatic chicken door (Read 214 times) previous topic - next topic

mike_cz

Hello guys,

I would like to ask you for help. I do have a automatic door opening using actuator. It is based on the time (for every single day).
Unfortunately, I am lost with the code. even if I have declared variables as "long" it does not return me values bigger than 65535.
I would appreciate any help with this.

Thank you in advance

P.S: code is too long, so pasting as attachment

larryd

#1
Mar 25, 2020, 05:55 pm Last Edit: Mar 25, 2020, 05:58 pm by larryd
" does not return me values bigger than 65535."

Because you are using an 'int' integer.

Use 'unsigned long'.



- word (16 bit) (unsigned int) - unsigned number from 0-65535

- unsigned long (32 bit) - unsigned number from 0-4,294,967,295. The most common usage of this is to store the result of the millis() function, which returns the number of milliseconds the current code has been running




No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

mike_cz

Hmm, I thought that I use long... as you can see in the code

Code: [Select]

static const long sunsetAr[] PROGMEM = {62760,62820,62820,62880,62940,63000,....

aarg

Why store the sun position when you can easily calculate it?
https://github.com/KenWillmott/SolarPosition
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

freedomlantern

I'm a newbie and building an automatic chicken door also. I find your code very interesting. If you want the door to open and close at sunrise and sunset, wouldn't it be easier just to use an light detecting resistor? That is what I am using currently, and this way you won't have to store the sunrise/sunset times.

mike_cz

Solved - converted to minutes. so no "long" is needed. Thanks to guys in CZ :)

PaulRB

#6
Mar 26, 2020, 08:31 am Last Edit: Mar 26, 2020, 08:32 am by PaulRB
wouldn't it be easier just to use an light detecting resistor?
It's quite difficult to get right using an LDR. Affected by weather conditions, easily fooled by partly cloudy skies etc.. Chooks not fooled by such things!

PaulRB

Hmm, I thought that I use long... as you can see in the code

Code: [Select]

static const long sunsetAr[] PROGMEM = {62760,62820,62820,62880,62940,63000,....

You need to put "UL" after each number literal, e.g. "62760UL,62820UL"...

Go Up