In function 'void setup()':
error: expected unqualified-id before '.' token
I've searched the forum and references and cann't figure out what I'm doing wrong. thanks
my code looks like this:
#include <SoftwareSerial.h>
int val = 0;
char code [10];
int byteread = 0;
int EnPin = 2;
void setup()
{
Serial.begin(2400);
pinMode(2,OUTPUT);
SoftwareSerial(7,8);
SoftwareSerial.begin(9600);
}
void loop()
{
digitalWrite(EnPin,LOW);
if (Serial.available()>0)
{
if((val = Serial.read()) == 10)
{
byteread=0;
while (byteread < 10)
{
if (Serial.available()>0)
{
val = Serial.read();
if ((val == 10) || (val == 13))
{
break;
}
code[byteread]=val;
byteread++;
}
}
if (byteread==10)
{
Serial.print("Tag code is ");
Serial.println(code);
}
digitalWrite(EnPin,HIGH);
delay(500);
}
}
} Small Bio
SoftwareSerial doesn't work quite the same way as the regular Serial. You need to declare an instance of it, then call begin(), etc. on that instance not on SoftwareSerial. See the example at:[quote=Brown post_id=260 time=1488550253 user_id=84]Every time I try to bring softwareserial into my code I get this error:
In function 'void setup()':
error: expected unqualified-id before '.' token
I've searched the forum and references and cann't figure out what I'm doing wrong. thanks
my code looks like this:
#include <SoftwareSerial.h>
int val = 0;
char code [10];
int byteread = 0;
int EnPin = 2;
void setup()
{
Serial.begin(2400);
pinMode(2,OUTPUT);
SoftwareSerial(7,8);
SoftwareSerial.begin(9600);
}
void loop()
{
digitalWrite(EnPin,LOW);
if (Serial.available()>0)
{
if((val = Serial.read()) == 10)
{
byteread=0;
while (byteread < 10)
{
if (Serial.available()>0)
{
val = Serial.read();
if ((val == 10) || (val == 13))
{
break;
}
code[byteread]=val;
byteread++;
}
}
if (byteread==10)
{
Serial.print("Tag code is ");
Serial.println(code);
}
digitalWrite(EnPin,HIGH);
delay(500);
}
}
}[/quote]





































