loading
 
mcu_com
amdaa from Egypt  [1 posts]
11 year
hi guys iam new in the roborealm and tired to make commencation between the roborealm and arduino atmega 1280 useing mcu_comm
i see all the forum and idid not understand the massege from the roborealm
it will be number explain the mailbox or word which i wrote in mailbox?????


i write this code which simply is resive data from roborealm and start flashing according to the number of mailbox not the value of the mailbox
but nothing don itry this code alone in arduino atmega 1280 work but whene i connect the roborealm no flasing at all but the led RX in the arduino boared flushing that mean there are data resived
what it kind and what is form???????????????

------------------------------------------------------------------------------------------------
String readString = String(100);  //stores the entire string up to a comma
String parce1 = String(10);       //first part of the string up to a space
String parce2 = String(10);       //second part of the string
int pos = 0;                      //stores the length of the string
int ind1 = 0;                     //position of space in string
int a=53;
int b=52;
int c=50;
                                  //my commands and values are 3 digit numbers
char elstringoUno[4];             //character array of the first part of the string
char elstringoDos[4];             //character array of the second part of the string
void setup()
{
  pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
    Serial.begin(9600);
}
  
void loop()
{
  while (Serial.available()) {
        delay(10);  
          if (Serial.available() >0) {
            char c = Serial.read();  //gets one byte from serial buffer
            if (c == ',') { goto parce;}  
              readString = readString + c;  //puts the char at end of the string
            } //end of if statement
          } //end of if statement
          //Serial.println(readString);
     parce:  
      if (readString.length() >0) {
        pos = readString.length(); //capture string length
        ind1 = readString.indexOf(' '); //position of the space
        parce1 = readString.substring(0, ind1); //first part of string
        parce2 = readString.substring(ind1+1, pos); //second part of string
        readString="";  //empties the readString for the next command
        parce1.toCharArray(elstringoUno, 4);  //turns 1st part of string into char array
        parce2.toCharArray(elstringoDos, 4);  //turns 2nd part of string into char array
      unsigned  int kommand, tvalue;  //will be the number of the command and value sent
        kommand = atoi(elstringoUno);  //turns the 1st char array into an integer
        tvalue = atoi(elstringoDos);   //turns the 2nd char array into an integer
       digitalWrite(b,HIGH);
switch (kommand)
    {        
      case  111:      //Move myServoOne to a value
for(int i=0;i<1;i++){
  digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  222:      //Move myServoTwo to a value
for(int i=0;i<2;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  333:      //Move myServoTwo to a value
for(int i=0;i<3;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  444:      //Move myServoTwo to a value
for(int i=0;i<4;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  500:      //Move myServoTwo to a value
for(int i=0;i<5;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  501:      //Move myServoTwo to a value
for(int i=0;i<6;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  600:      //Move myServoTwo to a value
for(int i=0;i<7;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  601:      //Move myServoTwo to a value
for(int i=0;i<8;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  700:      //Move myServoTwo to a value
for(int i=0;i<9;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  701:      //Move myServoTwo to a value
for(int i=0;i<10;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  800:      //Move myServoTwo to a value
for(int i=0;i<11;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;
      case  801:      //Move myServoTwo to a value
for(int i=0;i<12;i++){digitalWrite(a,HIGH);
digitalWrite(c,HIGH);
delay(1000);
digitalWrite(a,LOW);
digitalWrite(c,LOW);
delay(1000);}
      break;

    } //end of switch statement
    digitalWrite(b,LOW);
//second:
delay(1000);
digitalWrite(b,LOW);
  } //end of if statement

} //end of void loop

------------------------------------------

note i tracking the face of humen if in range of there is massege will apair in the glcd contain his name
and thank for all  
Anonymous 11 year
Amdaa,

It is a little difficult to understand what you are asking for but the above code have a couple problems. The main issue is the delay(1000) which you have in the flashing ... this will cause the Arduino to stop listening to any serial connections during that time.

The MCU code provides a framework that includes both a mailbox number (or id) and the value of that mailbox. Its a more complicated but reliable method of communication to the Arduino that what you code is doing .. but is fundamentally the same.

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index