I have an Arduino Mega and uno, both connected to an lcd display. The Mega filled the screen with the same code noticeable slower.
So i made 2 tests:
- Calculation
long t;
long x;
void setup()
{
Serial.begin(9600);
}
void loop()
{
t = millis();
for(unsigned int a = 0; a <= 10000; a++)
{
if(a % 2 == 1)
{
x = x*2;
}
else
{
x = x/2;
}
}
Serial.println(millis()- t);
}
Result
both took 202-204ms
- Write ports
long t;
long x;
void setup()
{
Serial.begin(9600);
}
void loop()
{
t = millis();
for(unsigned int a = 0; a <= 10000; a++)
{
if(a % 2 == 1)
{
digitalWrite(11,1);
}
else
{
digitalWrite(11,0);
}
}
Serial.println(millis()- t);
}
Result
Mega: 72-73ms
uno: 54-55ms
Both use an PWM Pin
Anybody here with similar results?
So the Mega is slower at Writing on the ports because he has more I/O?Can someone explain it to me? Im really dissapointed :.