aiuto per codice arduino ?

sto realizzando un codice per il mio lettore rfid in cui quando passo il lettore card deve azionare il mio servo motore ( mi serve per un cancello fatto in legno da me ) ma non mi funziona
ecco il codice

// RFID reader for Arduino 
// Wiring version by BARRAGAN <http://people.interaction-ivrea.it/h.barragan> 
// Modified for Arudino by djmatic


 int  val = 0; 
 char code[10]; 
 int bytesread = 0; 
 #include <Servo.h>
 Servo myservo;
 int pos = 0;

 void setup() { 

 Serial.begin(2400); // RFID reader SOUT pin connected to Serial RX pin at 2400bps 
 pinMode(2,OUTPUT);   // Set digital pin 2 as OUTPUT to connect it to the RFID /ENABLE pin 
 digitalWrite(2, LOW);                  // Activate the RFID reader
 myservo.attach(9);
 }  


 void loop() { 

  if(Serial.available() > 0) {          // if data available from reader 
    if((val = Serial.read()) == 10) {   // check for header 
      bytesread = 0; 
      while(bytesread<10) {              // read 10 digit code 
        if( Serial.available() > 0) { 
          val = Serial.read(); 
          if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading 
            break;                       // stop reading 
          } 
          code[bytesread] = val;         // add the digit           
          bytesread++;                   // ready to read next digit  
        } 
      } 
      if(bytesread == 10) {              // if 10 digit read is complete 
        Serial.print("TAG code is: ");   // possibly a good TAG 
        Serial.println(code);            // print the TAG code 
      for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  
 } 
      bytesread = 0; 
      digitalWrite(2, HIGH);                  // deactivate the RFID reader for a moment so it will not flood
           delay(1500);                       // wait for a bit 
           digitalWrite(2, LOW);                  // Activate the RFID reader
    } 
  } 
 } 

// extra stuff
// digitalWrite(2, HIGH);             // deactivate RFID reader

da cosa dipende l'errore e come posso risolvere ? grazie

Daniel ...
... stai violando il regolamento a raffica ... IL CROSS-POSTING NON E' PERMESSO !!!

Tu hai messo praticamente lo stesso identico post QUI poi QUI quindi QUI ed infine questo post !!!

Decidi UN SOLO post e continua a chiedere su quello ... gli altri verranno eliminati dal mod !!!

Guglielmo

Oltretutto io rispondo in quello sotto hardware, dove NON metti nessun codice, obbligandomi a fare supposizioni.
Grazie per avermi fatto perdere tempo. ]:smiley:

Multi cross-posting:
http://forum.arduino.cc/index.php?topic=227315.msg1643125#msg1643125
http://forum.arduino.cc/index.php?topic=227306.msg1643044#msg1643044
http://forum.arduino.cc/index.php?topic=227304.msg1643028#msg1643028
http://forum.arduino.cc/index.php?topic=227290.msg1643004#msg1643004
http://forum.arduino.cc/index.php?topic=227287.msg1642991#msg1642991
http://forum.arduino.cc/index.php?topic=227291.msg1642965#msg1642965
http://forum.arduino.cc/index.php?topic=227290.msg1642961#msg1642961
http://forum.arduino.cc/index.php?topic=227287.msg1642939#msg1642939