Skip to content

Commit 269e6fc

Browse files
Peter Van Hoyweghen
authored andcommitted
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.
1 parent adb8831 commit 269e6fc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

build/shared/examples/ArduinoISP/ArduinoISP.ino

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
void pulse(int pin, int times);
6868

6969
void setup() {
70-
Serial.begin(9600);
70+
Serial.begin(19200);
7171
SPI.setDataMode(0);
7272
SPI.setBitOrder(MSBFIRST);
7373
// Clock Div can be 2,4,8,16,32,64, or 128
@@ -111,14 +111,17 @@ parameter param;
111111
uint8_t hbval = 128;
112112
int8_t hbdelta = 8;
113113
void heartbeat() {
114+
static unsigned long last_time = 0;
115+
unsigned long now = millis();
116+
if ((now - last_time) < 40)
117+
return;
118+
last_time = now;
114119
if (hbval > 192) hbdelta = -hbdelta;
115120
if (hbval < 32) hbdelta = -hbdelta;
116121
hbval += hbdelta;
117122
analogWrite(LED_HB, hbval);
118-
delay(20);
119123
}
120124

121-
122125
void loop(void) {
123126
// is pmode active?
124127
if (pmode) digitalWrite(LED_PMODE, HIGH);

0 commit comments

Comments
 (0)