Hello,
I am a new comer to this forum. I am now trying to code the Atlas Scientific evn RGB sensor on Arduino Uno. The problem is when i print the data on the Serial motonitor, all the data are 0. I am so confused and i really need some help.
Here is my code up to now
(CODE TAGS PLEASE)
#include <SoftwareSerial.h> 
int RX = 2;
int TX = 3;
SoftwareSerial mySerial(RX,TX);
String first = ""; 
String second = "";
String third = "";
String forth = "";
String fifth = "";
String sixth = "";
String seventh = "";
String eighth = "";
String excess = "";
String input_string = ""; 
boolean input_stringcomplete = false; 
boolean sensor_stringcomplete = false; 
int commacount = 0;
byte  byteRead;
void setup(){ 
  
Serial.begin(38400); 
mySerial.begin(38400);
mySerial.print('C');
excess.reserve(100);
input_string.reserve(20); 
first.reserve(20);
second.reserve(20);
third.reserve(20);
forth.reserve(20);
fifth.reserve(20);
sixth.reserve(20);
seventh.reserve(20);
eighth.reserve(20);
}
void serialEvent() { 
char inchar = (char)Serial.read(); 
input_string += inchar; 
if(inchar == 13) {input_stringcomplete = true;} 
if (inchar == 44)
{
 commacount++;
} 
if (commacount == 0)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   first += inchar;
 }
}
else if (commacount == 1)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   second += inchar;
 }
}
else if (commacount == 2)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   third += inchar;
 }
}
else if (commacount == 3)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   forth += inchar;
 }
}
else if (commacount == 4)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   fifth += inchar;
 }
}
else if (commacount == 5)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   sixth += inchar;
 }
}
else if (commacount == 6)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   seventh += inchar;
 }
}
else if (commacount == 7)
{
 if (inchar == 44)
 {
   excess += inchar;
 }
 else
 {
   eighth += inchar;
 }
}
if(inchar == 13) {sensor_stringcomplete = true;} 
}
void loop(){ 
 
if (input_stringcomplete){ 
Serial.print(input_string); 
input_string = ""; 
input_stringcomplete = false; 
}
if (sensor_stringcomplete)
{
  int firstint = first.toInt();
  int secondint = second.toInt();
  int thirdint = third.toInt();
  int forthint = forth.toInt();
  int fifthint = fifth.toInt();
  int sixthint = sixth.toInt();
  int seventhint = seventh.toInt();
  int eighthint = eighth.toInt();
 
  Serial.println(firstint);
  Serial.println(secondint); 
  Serial.println(thirdint); 
  Serial.println(forthint); 
  Serial.println(fifthint);
  Serial.println(sixthint);
  Serial.println(seventhint);
  Serial.println(eighthint);
  
  first = "";
  second= "";
  third= "";
  forth= "";
  fifth= "";
  sixth= "";
  seventh= "";
  eighth= "";
  
  excess="";
  commacount=0;
  
  sensor_stringcomplete = false; 
}
}


