Communicating via serial, arduino to battery device
sorry relatively new arduino. wanting transmit code in ascii device operating @ 9600 baud , want graph example in graph form ex. battery volt. having trouble figuring serial protocol use , pins use. device transmits @ 5 volt signal , has rj 45 plug on (phone plug 6 wires). starting appreciated. in advance.
if new should start spending day or 2 @ tutorial section of arduino.cc there lot learn including serial communication.
serial uses pin 0 , 1 , minimal sketch captures string device looks like
code: [select]
char buffer[80];
int idx =0;
void setup()
{
serial.begin(9600);
}
void loop()
{
if (serial.available() >0)
{
char c = serial.read();
buffer[idx] = c;
if (c == ';') // check ;
{
buffer[idx] = 0; // end string
// buffer contains string
// can read data
idx = 0;
}
else
{
idx++;
if (idx==80) idx=0; // prevent overflow.
}
}
// other things here
}
Arduino Forum > Using Arduino > Project Guidance > Communicating via serial, arduino to battery device
arduino
Comments
Post a Comment