Skip to content

Commit fbfd869

Browse files
committed
Add check to Arduino sketch to wait with sending data
1 parent 275e2fd commit fbfd869

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

libraries/Portenta_Camera/examples/CameraCaptureRawBytes/CameraCaptureRawBytes.ino

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ CameraClass cam;
44
uint8_t fb[320*240];
55

66
void setup() {
7-
8-
Serial.begin(921600);
7+
Serial.begin(921600);
98

109
// Init the cam QVGA, 30FPS
1110
cam.begin(CAMERA_R320x240, 30);
1211
}
1312

1413
void loop() {
1514
// put your main code here, to run repeatedly:
16-
if (Serial) {
17-
// Grab frame and write to serial
18-
if (cam.grab(fb) == 0) {
19-
Serial.write(fb, 320*240);
20-
}
15+
16+
// Wait until the receiver acknowledges
17+
// that they are ready to receive new data
18+
while(Serial.read() != 1){};
19+
20+
// Grab frame and write to serial
21+
if (cam.grab(fb) == 0) {
22+
Serial.write(fb, 320*240);
2123
}
24+
2225
}

0 commit comments

Comments
 (0)