Due vs. Uno

I just had a uno break on me so I started using the due I had just bought. A code I ran just yesterday on the uno is no longer working now that I’m using the Due. Are the pins different other than the increased number of them? Here is the code:

// Initializes pin values
int ledPin = 9; 
int throttle = 7; 

void setup() {
  // initialize throttle as input and ledPin as output
  pinMode(throttle, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // takes the time the pulse is high and low and then calculates the duty cylce
  float inputHigh = pulseIn(7, HIGH);
  float inputLow = pulseIn(7, LOW);
  float dutyCycle = (inputHigh / (inputHigh + inputLow)) * 100;
  
  // maps the min and max duty cycle to the min and max brightness of the LED
  float outputValue = (dutyCycle - 5.0) * (255.0/4.1);
  analogWrite(ledPin, outputValue);
  
  // Turns the LED off if there is no input or too much input
  if(dutyCycle < 5.3 or dutyCycle > 9.1){
    analogWrite(ledPin, 0);
  }
}

Are pins 7 and 9 different on the due than the uno?

I just had a uno break on me so I started using the due I had just bought. A code I ran just yesterday on the uno is no longer working now that I’m using the Due. Are the pins different other than the increased number of them? Here is the code:

// Initializes pin values
int ledPin = 9; 
int throttle = 7; 

void setup() {
  // initialize throttle as input and ledPin as output
  pinMode(throttle, INPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // takes the time the pulse is high and low and then calculates the duty cylce
  float inputHigh = pulseIn(7, HIGH);
  float inputLow = pulseIn(7, LOW);
  float dutyCycle = (inputHigh / (inputHigh + inputLow)) * 100;
  
  // maps the min and max duty cycle to the min and max brightness of the LED
  float outputValue = (dutyCycle - 5.0) * (255.0/4.1);
  analogWrite(ledPin, outputValue);
  
  // Turns the LED off if there is no input or too much input
  if(dutyCycle < 5.3 or dutyCycle > 9.1){
    analogWrite(ledPin, 0);
  }
}

Are pins 7 and 9 different on the due than the uno?

What do you mean no longer working? Notice that the Due pins will supply only 3.3V. If your device requires 5V, you'd need a logic converter.

Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.

Threads merged.

  • Moderator

It was actually a problem with the power supply and not the boards. On the second trial I had the input device (a RC controller receiver) and the arduino powered from different sources. Not sure why this caused the problem but it did.