Skip to content

Instantly share code, notes, and snippets.

@youkidearitai
Created October 25, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youkidearitai/736b5d1547b88852b88bcc84400017b4 to your computer and use it in GitHub Desktop.
Save youkidearitai/736b5d1547b88852b88bcc84400017b4 to your computer and use it in GitHub Desktop.
// #include <SoftwareSerial.h>
#include <SD.h>
#include <SPI.h>
#define CAMERA_RX 3
#define CAMERA_TX 2
#define BAUD_RATE 115200
#define chipSelect 4
File logFile;
void setup() {
pinMode(8, INPUT_PULLUP);
if(chipSelect != 10) pinMode(10, OUTPUT); // SS on Uno, etc.
// put your setup code here, to run once:
Serial.begin(BAUD_RATE);
Serial1.begin(BAUD_RATE);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
SD.begin(chipSelect);
logFile = SD.open("TEST.TXT", FILE_WRITE);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(8) == LOW) {
logFile.close();
}
if (Serial1.available()) {
Serial.write(Serial1.read());
}
if (Serial.available()) {
byte r = Serial.read();
Serial1.write(r);
logFile.write(r);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment