From ad2a32fd24edbe4e6052995594badacfa4cd2bab Mon Sep 17 00:00:00 2001 From: Peter Van Hoyweghen Date: Fri, 13 Feb 2015 20:48:40 +0100 Subject: [PATCH] Avoid delay in heartbeat. That way we can also set the baudrate back to the value used in the IDE. In fact, with this fix, baud rates of up to 115200 work also. --- .../11.ArduinoISP/ArduinoISP/ArduinoISP.ino | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino index 7b67f6e54..9ad5a1b33 100644 --- a/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino +++ b/build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino @@ -67,7 +67,7 @@ void pulse(int pin, int times); void setup() { - Serial.begin(9600); + Serial.begin(19200); SPI.setDataMode(0); SPI.setBitOrder(MSBFIRST); // Clock Div can be 2,4,8,16,32,64, or 128 @@ -111,18 +111,17 @@ parameter param; uint8_t hbval = 128; int8_t hbdelta = 8; void heartbeat() { - if (hbval > 192) { - hbdelta = -hbdelta; - } - if (hbval < 32) { - hbdelta = -hbdelta; - } + static unsigned long last_time = 0; + unsigned long now = millis(); + if ((now - last_time) < 40) + return; + last_time = now; + if (hbval > 192) hbdelta = -hbdelta; + if (hbval < 32) hbdelta = -hbdelta; hbval += hbdelta; analogWrite(LED_HB, hbval); - delay(20); } - void loop(void) { // is pmode active? if (pmode) {