Hi!
I'm trying to send data from a Nano v3.0 to a DUE.
The communication is one way only.
I know about the 5v vs 3v3 issue, so i bought this device from Sparkfun:
Sparkfun LLC
The circuit has 8 potentiometers connected to the Nano, this board has to read the values and send them to the DUE, along with an identification number for the potentiometers.
LEDs connected to PWM pins on the DUE should light up for debug purposes.
This is the wiring:

This is the code for the Nano:
#define pot1 A0
#define pot2 A1
#define pot3 A2
#define pot4 A3
#define pot5 A4
#define pot6 A5
#define pot7 A6
#define pot8 A7
int lastPot1 = 0;
int lastPot2 = 0;
int lastPot3 = 0;
int lastPot4 = 0;
int lastPot5 = 0;
int lastPot6 = 0;
int lastPot7 = 0;
int lastPot8 = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
//Potentiometer 1
int currentPot1 = analogRead(pot1);
currentPot1 = map(currentPot1, 0, 1023, 0 ,255);
if (currentPot1 != lastPot1) {
lastPot1 = currentPot1;
Serial.print("2,");
Serial.println(currentPot1);
}
//Potentiometer 2
int currentPot2 = analogRead(pot2);
currentPot2 = map(currentPot2, 0, 1023, 0 ,255);
if (currentPot2 != lastPot2) {
lastPot2 = currentPot2;
Serial.print("3,");
Serial.println(currentPot2);
}
//Potentiometer 3
int currentPot3 = analogRead(pot3);
currentPot3 = map(currentPot3, 0, 1023, 0 ,255);
if (currentPot3 != lastPot3) {
lastPot3 = currentPot3;
Serial.print("4,");
Serial.println(currentPot3);
}
//Potentiometer 4
int currentPot4 = analogRead(pot4);
currentPot4 = map(currentPot4, 0, 1023, 0 ,255);
if (currentPot4 != lastPot4) {
lastPot4 = currentPot4;
Serial.print("5,");
Serial.println(currentPot4);
}
//Potentiometer 5
int currentPot5 = analogRead(pot5);
currentPot5 = map(currentPot5, 0, 1023, 0 ,255);
if (currentPot5 != lastPot5) {
lastPot5 = currentPot5;
Serial.print("6,");
Serial.println(currentPot5);
}
//Potentiometer 6
int currentPot6 = analogRead(pot6);
currentPot6 = map(currentPot6, 0, 1023, 0 ,255);
if (currentPot6 != lastPot6) {
lastPot6 = currentPot6;
Serial.print("7,");
Serial.println(currentPot6);
}
//Potentiometer 7
int currentPot7 = analogRead(pot7);
currentPot7 = map(currentPot7, 0, 1023, 0 ,255);
if (currentPot7 != lastPot7) {
lastPot7 = currentPot7;
Serial.print("8,");
Serial.println(currentPot7);
}
//Potentiometer 8
int currentPot8 = analogRead(pot8);
currentPot8 = map(currentPot8, 0, 1023, 0 ,255);
if (currentPot8 != lastPot8) {
lastPot8 = currentPot8;
Serial.print("9,");
Serial.println(currentPot8);
}
}
And this is the code for the DUE:
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
while (Serial.available() > 0) {
int pin = Serial.parseInt();
int power = Serial.parseInt();
if (Serial.read() == '\n') {
analogWrite(pin, power);
}
}
}
The problem is that the entire thing doesn't work at all! The only thing that works is the TX LED on the Nano, which blinks as expected.
Any help appreciated. Thank you all!!!