You can set the clock prescaler for that:
void setup() {
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
}
This is explained in section 10.12 and 10.13 of the ATmega2560 datasheet.
Of course, changing the clock frequency will mess with the time-related
function (millis()
, delay()
and co.) and the baud rate of the serial
port.
Edit: Here is a small program to demonstrate the slowing of the clock:
//#define SLOW_CLOCK
void setup()
{
#ifdef SLOW_CLOCK
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
#endif
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
This makes the LED flash at 1 Hz. If you uncomment the line
#define SLOW_CLOCK
, it instead flashes at 0.5 Hz.
You can set the clock prescaler for that:
void setup() {
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
}
This is explained in section 10.12 and 10.13 of the ATmega2560 datasheet.
Of course, changing the clock frequency will mess with the time-related
function (millis()
, delay()
and co.) and the baud rate of the serial
port.
You can set the clock prescaler for that:
void setup() {
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
}
This is explained in section 10.12 and 10.13 of the ATmega2560 datasheet.
Of course, changing the clock frequency will mess with the time-related
function (millis()
, delay()
and co.) and the baud rate of the serial
port.
Edit: Here is a small program to demonstrate the slowing of the clock:
//#define SLOW_CLOCK
void setup()
{
#ifdef SLOW_CLOCK
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
#endif
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(500);
digitalWrite(LED_BUILTIN, LOW);
delay(500);
}
This makes the LED flash at 1 Hz. If you uncomment the line
#define SLOW_CLOCK
, it instead flashes at 0.5 Hz.
You can set the clock prescaler for that:
void setup() {
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
}
This is explained in section 10.12 and 10.13 of the ATmega2560 datasheet .
Of course, changing the clock frequency will mess with the time-related
function (millis()
, delay()
and co.) and the baud rate of the serial
port.
You can set the clock prescaler for that:
void setup() {
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
}
You can set the clock prescaler for that:
void setup() {
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
}
This is explained in section 10.12 and 10.13 of the ATmega2560 datasheet .
Of course, changing the clock frequency will mess with the time-related
function (millis()
, delay()
and co.) and the baud rate of the serial
port.
You can set the clock prescaler for that:
void setup() {
noInterrupts();
CLKPR = _BV(CLKPCE); // enable change of the clock prescaler
CLKPR = _BV(CLKPS0); // divide frequency by 2
interrupts();
}