Ok, so i am creating a pond Controller with an arduino nano as the main controller and an app, made on MIT app inventor 2, communicating over Bluetooth with the arduino. my Problem is that i have the phone app send over a list of all the data points every 100 milliseconds, and the arduino receives them just fine, with the RX led flashing, but it wont process the data or print out what it has gotten for a long time. Then is will suddenly print it all at once and go back to collecting it and doing nothing. I cant find any correlation with when it decides to print what it has received.
#include <EEPROM.h>
#include <Wire.h>
#include "StringSplitter.h"
#include "RTClib.h"
#define Port1 4
#define Port2 5
#define Port3 6
#define Port4 7
#define R 10
#define G 11
#define B 12
#define DeBug 8
StringSplitter *splitter;
String AsciiIN;
int Update;
int P1State;
int P2State;
int P3State;
int P4State;
RTC_DS1307 RTC;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Wire.begin();
RTC.begin();
pinMode (DeBug, INPUT);
pinMode (Port1, OUTPUT); //Sets Port 1-4 As Outputs
pinMode (Port2, OUTPUT);
pinMode (Port3, OUTPUT);
pinMode (Port4, OUTPUT);
pinMode (R, OUTPUT); //Sets RGB Pins As Outputs
pinMode (G, OUTPUT);
pinMode (B, OUTPUT);
pinMode (13, OUTPUT);
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
Serial.println("Start Up Done");
}
void loop() {
// put your main code here, to run repeatedly:
DateTime now = RTC.now();
if (Serial.available() > 0) {
AsciiIN = Serial.readString();
splitter = new StringSplitter(AsciiIN, ',', 5); // new StringSplitter(string_to_split, delimiter, limit)
String Refresh = splitter->getItemAtIndex(0);
String P1 = splitter->getItemAtIndex(1);
String P2 = splitter->getItemAtIndex(2);
String P3 = splitter->getItemAtIndex(3);
String P4 = splitter->getItemAtIndex(4);
String RR = splitter->getItemAtIndex(5);
String GG = splitter->getItemAtIndex(6);
String BB = splitter->getItemAtIndex(7);
Update == Refresh.toInt();
Serial.println(AsciiIN);
Serial.println(Up);
Refresh = "";
if (P1 == "On") {
digitalWrite(Port1, HIGH);
P1State = 1;
}
if (P1 == "OFF") {
digitalWrite(Port1, LOW);
P1State = 2;
}
if (P2 == "On") {
digitalWrite(Port2, HIGH);
P2State = 1;
}
if (P2 == "OFF") {
digitalWrite(Port2, LOW);
P1State = 2;
}
if (P3 == "On") {
digitalWrite(Port3, HIGH);
P2State = 1;
}
if (P3 == "OFF") {
digitalWrite(Port3, LOW);
P3State = 2;
}
if (P4 == "On") {
digitalWrite(Port4, HIGH);
P4State = 1;
}
if (P4 == "OFF") {
digitalWrite(Port4, LOW);
P4State = 2;
}
}
if (Update == 1492) {
digitalWrite(13, HIGH);
Serial.print("P1");
Serial.print(P1State);
Serial.print(",");
Serial.print("P2");
Serial.print(P2State);
Serial.print(",");
Serial.print("P3");
Serial.print(P3State);
Serial.print(",");
Serial.print("P4");
Serial.print(P4State);
Serial.print(",");
}
if (digitalRead(DeBug) == HIGH) {
Serial.print("Ascii Translation-");
Serial.println(AsciiIN);
/*
Serial.print("1Start-");
Serial.println(Start1);
Serial.print("1End-");
Serial.println(End1);
Serial.print("2Start-");
Serial.println(Start2);
Serial.print("2End-");
Serial.println(End2);
Serial.print("3Start-");
Serial.println(Start3);
Serial.print("3End-");
Serial.println(End3);
Serial.print("4Start-");
Serial.println(Start4);
Serial.print("4End-");
Serial.println(End4);
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000);
*/
}
AsciiIN = "";
delay(100);
}
and my MIT Inventor App. Any help is appreciated, Please and thank you. Edit- "The forum will not allow me to add my .aia app file so if you know of any way I can share that please post."