Serial - Is possible to put a received data in an array of char ?


good evening,
i need read char serial , compose array of char.
what see arduino received on char of time need build array of char have word.
below reported simple sketch:

code: [select]
int incomingbyte = 0;   // incoming serial data

void setup() {
       serial.begin(9600);  
       
}

void loop() {

       // send data when receive data:
       if (serial.available() > 0) {
               // read incoming byte:
               incomingbyte = serial.read();
               serial.print((char)incomingbyte);
             }
}


i think possible use :
code: [select]
stream.readbytesuntil(character, buffer, length)

but didn't know ho use it,

could give simple sketch build array incoming data on serial ?

thanks 1000000 support
gnusso



assuming can write variable, array definitions, void setup() go this:
code: [select]

x=0;
void loop(){
if (done_receiving == 0){ // more data expected
if (serial.available()>0){
incomingarray [x] = serial.read();
  if (incomingarray [x] == done_character)
  { done_receiving = 1;
    x = 0;}
  else {x=x+1;}
} // end serial available
} // end done check
} // end void loop


Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > Serial - Is possible to put a received data in an array of char ?


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial