Hello everyone,
I have two boards: 1. Arduino UNO R3 and 2. Arduino DUE R3-E.
I am using Arduino 1.5.7 on Windows 8.1 64 bit
My problem is with a piece of code that works fine on UNO but not on DUE.
/*Program execution time*/
unsigned long time;
unsigned long number = 1234567UL;
void setup()
{
Serial.begin(9600);
for(unsigned long counter = 1UL; counter != number + 1; counter++)
{
if(number % counter == 0)
{
Serial.println(counter); //Print the factors
}
}
time = millis();
Serial.print("Time: ");
Serial.println(time / 1000); //Print time in seconds
}
void loop()
{
;
}
On the UNO the output on the serial monitor:
1
127
9721
1234567
Time: 47
But on DUE the same code generates a compile time error:
Arduino: 1.5.7 (Windows 8), Board: "Arduino Due (Programming Port)"
Build options changed, rebuilding all
Progexecutiontiming.ino:3:15: error: 'long unsigned int time' redeclared as different kind of symbol
In file included from c:\program files (x86)\arduino\hardware\tools\gcc-arm-none-eabi-4.8.3-2014q1\arm-none-eabi\include\stdlib.h:11:0,
from C:\Program Files (x86)\Arduino\hardware\arduino\sam\cores\arduino/Arduino.h:24,
from Progexecutiontiming.ino:3:
c:\program files (x86)\arduino\hardware\tools\gcc-arm-none-eabi-4.8.3-2014q1\arm-none-eabi\include\time.h:47:11: error: previous declaration of 'time_t time(time_t*)'
time_t _EXFUN(time, (time_t _timer));
^
Progexecutiontiming.ino: In function 'void setup()':
Progexecutiontiming.ino:16:8: error: assignment of function 'time_t time(time_t)'
Progexecutiontiming.ino:16:8: error: cannot convert 'uint32_t {aka long unsigned int}' to 'time_t(time_t*) {aka long int(long int*)}' in assignment
Progexecutiontiming.ino:18:25: error: invalid operands of types 'time_t(time_t*) {aka long int(long int*)}' and 'int' to binary 'operator/'
Any help would be much appreciated. Thanks.