8000 Avoid delay in heartbeat. That way we can also set the baudrate back … · arduino/Arduino@ad2a32f · GitHub
[go: up one dir, main page]

Skip to content

Commit ad2a32f

Browse files
Peter Van HoyweghenPeter Van Hoyweghen
Peter Van Hoyweghen
authored and
Peter Van Hoyweghen
committed
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 aeaed27 commit ad2a32f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

build/shared/examples/11.ArduinoISP/ArduinoISP/ArduinoISP.ino

Lines changed: 8 additions & 9 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,18 +111,17 @@ parameter param;
111111
uint8_t hbval = 128;
112112
int8_t hbdelta = 8;
113113
void heartbeat() {
114-
if (hbval > 192) {
115-
hbdelta = -hbdelta;
116-
}
117-
if (hbval < 32) {
118-
hbdelta = -hbdelta;
119-
}
114+
static unsigned long last_time = 0;
115+
unsigned long now = millis();
116+
if ((now - last_time) < 40)
117+
return;
118+
last_time = now;
119+< 6D2B /span>
if (hbval > 192) hbdelta = -hbdelta;
120+
if (hbval < 32) hbdelta = -hbdelta;
120121
hbval += hbdelta;
121122
analogWrite(LED_HB, hbval);
122-
delay(20);
123123
}
124124

125-
126125
void loop(void) {
127126
// is pmode active?
128127
if (pmode) {

0 commit comments

Comments
 (0)
0