Hello,
I have to create a txt file by the name of a subject (person) in the sd card interfaced to the board. The name will be entered by the user in the android application. This name will be then received by my hardware board (adafruit feather M0 express interfaced with SD card) via bluetooth low energy which is configured with UART pins. I am able to receive the name character by character and see it on the serial monitor but i have to input the complete name like "Shivam Trivedi" and store in an array or string and then use this string or array to name the file. So i am not able to see the complete array when i am inputting the complete array at once. Here is my code that i am using.
Thanks,
Shivam
#include <SPI.h>
#include <SD.h>
#include <Arduino.h> // required before wiring_private.h
#include "wiring_private.h" // pinPeripheral() function
#include <U8x8lib.h>
#include <PCF8563.h>
PCF8563 pcf;
#include <Wire.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#define PIN 8
#define NUMPIXELS 1
#define SERIAL_BUFFER_SIZE 256
//char incomingData[50] ; // for incoming serial data
//int incomingSerialDataIndex = 0;
Uart Serial2 (&sercom1, 11, 10, SERCOM_RX_PAD_0, UART_TX_PAD_2);
void SERCOM1_Handler()
{
Serial2.IrqHandler();
}
char Filename[30];
File dataFile;
String Data;
void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial2.begin(9600);
Wire.begin();
pinPeripheral(10, PIO_SERCOM);
pinPeripheral(11, PIO_SERCOM);
delay(5000);
Serial.println("Enter Subject Name");
delay(1500);
unsigned long int time2;
time2 = millis();
while (time2<90000)
{
time2 = millis();
Data = Serial2.readStringUntil('\n'); // Add the incoming byte to the array
//incomingData[incomingSerialDataIndex] = Serial2.read(); // Add the incoming byte to the array
//incomingSerialDataIndex++; // Ensure the next byte is added in the next position
//Serial2.flush();
}
Serial.println ("Finished");
delay(2000);
Serial.println(Data);
}
void loop()
{
}