 # Sending Data From Two Pots Through Serial

I have a new project that involves sending data from two different potentiometers to another Arduino through serial. The problem I am facing is how the receiving Arduino is to determine what potentiometer the data it is processing is from. It will change two different PWM pins based on the data received. Does anyone have any suggestions of how I am to go about this task?

Imagine I have a sheet of paper with two columns of numbers on it. I start reading them out in row order. At some point, you walk into the room to copy down the numbers as I read them out. How would you know which number belonged in which column?

Because they are read in a certain order. So the receiver can take the first set of data and respond to it, then take the second set and respond but in the other way.

No. Think about it. You come into the room at some random point; you don't know if I'm reading from column one or column two.

Serial input basics will give you information on building a data packet, receiving the packet and parsing the data.

analogRead() returns two bytes. You can divide by 4 and just send 1 byte for the receiving Arduino to use as PWM output with analogWrite().

``````Sender:
Serial.write ((val0>>2));
Serial.write ((val1>>2));

if (Serial.available()>1){
analogWrite (PWM0pin, PWM0);
analogWrite (PWM1pin, PWM1);
}
``````

AWOL, I am not quite following what you are trying to get me to understand. Can you please explain?

If you are talking one Arduino to another through a single serial interface, the problem is easy.

The analog signal you are looking for would be a number from 0-1024. That would require you to use a int with a range from 0-32,000(roughly). Simply add an offset to one of the two. Ie. Signal 1 = 0-1024 the second could be 10,000-1,1024.

When you receive the data, simply test to see which one is above 10,000, subtract the 10,000 and read the number.

Using this technique, you could transmit/receive dozens of signals.

Thank you. That seems to be a very logical solution that I will implement