My arduino UNO board has connected to COM5, but why can't I upload it to the board
This is my code
const int StartByte=10;
const int StopByte=13;
const int tagLength=10;
const int enable=0;
const int Gled=13;
const int Rled=6;
int index=0;
const int number=5;
int serialNum=-1;
char tag[tagLength+1];
char card[number][tagLength+1]={"25005F805B","25005F40BB","25005F71AB","25005F45D5","25005F6707"};
void compTag(void);
void setup()
{
Serial.begin(2400);
pinMode(enable,OUTPUT);
pinMode(Gled,OUTPUT);
pinMode(Rled,OUTPUT);
digitalWrite(enable,LOW);
digitalWrite(Gled,LOW);
digitalWrite(Rled,LOW);
}
void loop()
{
if(Serial.available()>=tagLength+2)
{
if(Serial.read()==StartByte)
{
index=0;
while(index<tagLength)
{
tag[index]=Serial.read();
index++;
}
if(Serial.read()==StopByte)
{
tag[index]=0;
Serial.print("RFID tag is: ");
Serial.println(tag);
compTag();
}
}
}
}
void compTag(void)
{
int exact;
int i,j;
serialNum=-1;
for(i=0;i<number;i++)
{
exact=1;
for(j=0;j<tagLength;j++)
{
if(tag[j]!=card[i][j])
exact=0;
}
if(exact==1)
serialNum=i;
}
if(serialNum>=0)
{
digitalWrite(Gled,HIGH);
digitalWrite(Rled,LOW);
delay(1000);
digitalWrite(Gled,LOW);
digitalWrite(Rled,LOW);
}
else
{
digitalWrite(Gled,LOW);
digitalWrite(Rled,HIGH);
delay(1000);
digitalWrite(Gled,LOW);
digitalWrite(Rled,LOW);
}
}