Skip to content

Due analog read #1740

Closed
Closed
@donelsonas

Description

@donelsonas

I'm trying to read multiple analog sensors with the Due board. Reading one sensor works fine, but when I try to read two or more, the device returns garbage. This same code works fine on the Uno. I found a web posting about this issue and it has a work around that doesn't seem to work anymore.

Also, analogReference() does not compile with the due.

Here's my code:

int a, b, c, d;

void setup()
{
  Serial.begin(9600);
  Serial.println("Program is Starting");
}

void loop()
{
  a=analogRead(0);
  delay(50);
  a=analogRead(0);

  b=analogRead(1);
  delay(50);
  b=analogRead(1);

  c=analogRead(2);
  delay(50);
  c=analogRead(2);

  d=analogRead(3);
  delay(50);
  d=analogRead(3);  

  Serial.print("Port 0 ");
  Serial.println(a);
  Serial.print("Port 1 ");
  Serial.println(b);
  Serial.print("Port 2 ");
  Serial.println(c);
  Serial.print("Port 3 ");
  Serial.println(d);
  delay(1000);
}

Metadata

Metadata

Assignees

Labels

Board: Arduino DueApplies only to the DueComponent: CoreRelated to the code for the standard Arduino API

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions