bool badMHz(u32 v) { return v < 12 || v > 72; } // Helper function void handleSpeed(u8 * packet) { u32 arg; if (packetScanf(packet,"s%d\n",&arg) != 3 || badMHz(arg)) return; u8 mhz = arg; // Stash result in a byte EEPROM.write(0, &mhz, 1); // Write it to address 0 reenterBootloader(); // And reboot } void setup() { u8 mhz; EEPROM.read(0, &mhz, 1); // Read 1 byte from address 0 if (badMHz(mhz)) mhz = 72; // Default to 72MHz Processor.setMHz(mhz); // Set the processor speed Body.reflex('s',handleSpeed); // Create reflex to change speed and reboot } void loop() { println(Processor.getMHz()); // Report current speed delay(2000); // Wait a while }