laptop to arduino over serial


this second attempt @ this. want send colour data computer arduino on serial i've tried twice not luck serial working i'm not getting right data arduino here code.

int colourdata;// use on rainbowduino direct buffer rendering
int dataarray[8];// hold bits serial

void setup() {
serial.begin(9600); //set serial 9600 baud rate
}

void loop(){
 if (serial.available() > 8) {  
 getcolourdata();
 }
 
}

void getcolourdata(){
 for (int i=0; <=8; i++) {
   dataarray = serial.read();
 }
 colourdata = dataarray[0],dataarray[1],dataarray[2],dataarray[3],dataarray[4],dataarray[5],dataarray[6],dataarray[7];
}


as can see i'm putting serial data array i'm sure there better way need colourdata contain hex value i'm hoping use function on rainbowduino direct buffer rendering please can show best way go this.

quote
i want send colour data computer arduino on serial

first thing answer how sending data? bytes? text?

code: [select]
int dataarray[8];// hold bits serial
is "bits" in generic sense, or think storing 1 bit in 16 bit variable in array?

code: [select]
(int i=0; <=8; i++) {
  dataarray[i] = serial.read();
}

and if there aren't 8 bytes available read on each pass through loop, happens?

code: [select]
colourdata = dataarray[0],dataarray[1],dataarray[2],dataarray[3],dataarray[4],dataarray[5],dataarray[6],dataarray[7];
while valid c syntax, not think think does.

what going colourdata?


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > laptop to arduino over serial


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums