hello friends.
A few days ago I tried to run a mcp4261 with my arduino mega2560 without success.
I have made it work with my arduino uno but with my mega2560 I cannot.
I need your help.
I leave my code and schematic
I measure resistance between pins 6-7 and between 8-9
#include <SPI.h>
const int leftPot = B00010000; // potenciometros pines bajos
const int rightPot = B00000000 ; //potenciometro pines altos
const int slaveSelectPin = 53; //pin 10 arduino uno - pin 53 arduino mega2560
const int shutdownPin = 7;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("inicio");
pinMode (slaveSelectPin , OUTPUT);
pinMode (shutdownPin, OUTPUT);
SPI.begin ();
digitalWrite(shutdownPin, LOW);
delay(500);
digitalWrite(shutdownPin, HIGH); //Turn off shutdown
setPot(leftPot, 0);
setPot(rightPot, 0);
}
void loop() {
digitalWrite(shutdownPin, HIGH); //Turn off shutdown
for (int i = 0; i < 255; i++) {
setPot(leftPot, i);
setPot(rightPot, i);
delay(100);
Serial.println(i);
}
for (int i = 255; i > 0; i--) {
setPot(leftPot, i);
setPot(rightPot, i);
delay(100);
Serial.println(i);
}
}
void setPot(byte command, int potencia) {
digitalWrite(slaveSelectPin, LOW);
//B00010000 potenciometros pines bajos
//B00000000 potenciometro pines altos
SPI.transfer (command);
SPI.transfer (potencia);
digitalWrite(slaveSelectPin, HIGH);
}
I hope you can help my
