Jump to content
  • 0

Help with PMODDPOT and Arduino


shanham67

Question

All,

I spent a couple of hours trying to control a PMODDPOT with an Arduino Duemilanove this afternoon.  A sketch of my wiring is attached.  The code that I am working with is below.  Is it obvious to you guys what I am doing wrong here?  (NOTE: Vcc is 5.2V).  NOTE: I have some experience with arduino but this is my first project that uses SPI.   

Thanks in advance for your help.

 

#include <SPI.h>

static byte i;
const int slaveSelectPin = 10;

void setup() {
  // put your setup code here, to run once:
  
  pinMode(slaveSelectPin, OUTPUT);
  SPI.begin();
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:

  i++;

// have tried 14000000,1400000,140000,14000 for SpeedMaximum
//  (i.e the first parameter to SPISetup)
// have tried SPI_MODE0 thru SPI_MODE3).
// have tried both LSBFIRST and MSBFIRST
  SPI.beginTransaction(SPISettings(14000,MSBFIRST,SPI_MODE0));
  digitalWrite(slaveSelectPin, LOW);
  SPI.transfer(i);
  digitalWrite(slaveSelectPin,HIGH);
  SPI.endTransaction();
 
  delay(500);
  
  if(i>254){
    i=0;
  }
 
  Serial.println(i);
}

 

image (3).png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Well, you haven't said anything about what's going wrong, only that this code doesn't work.

Have you given any thought to the fact that most characters are signed?  If that's the case, if (i>254) will _never_ be true, since i will go from 127 to -128, and neither number will ever be greater than 254.

Are you struggling with a loop that never ends?

Dan

Link to comment
Share on other sites

Hi shanham67,

I was able to get the PmodDPOT to work with the attached code on the cerebot MX4ck. Remember that the SPI library works with SPI2 on the microcontroller. I have also attached a picture of how I have it connected. We will be adding an arduino based demo for the PmodDPOT shortly as well.

Thank you,

Jon

pmodDpot.ino

pict.zip

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...