Skip to content

Arduino 1.5.6-r2 Bug in AnalogRead() #2016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DenDanny opened this issue Apr 16, 2014 · 1 comment
Closed

Arduino 1.5.6-r2 Bug in AnalogRead() #2016

DenDanny opened this issue Apr 16, 2014 · 1 comment
Labels
Type: Duplicate Another item already exists for this topic

Comments

@DenDanny
Copy link

On an Arduino DUE::

The example sketch below does not work on 1.5.6-r2.

I have an LED connected between a digital and an analogue pin. But in 1.5.6-r2, once I use the AnalogRead() - the LED will no longer be 'controllable' using the pinMode/DigitalWrite. The sketch demonstrates this because (in 1.5.6-r2) the LED will stop blinking after the AnalogRead(); whilst in 1.5.4 this sketch runs flawlessly, and the LED blinks happily away -as expected...

All the best,
Danny.

// for Arduino DUE:
const int anode = 24;         // Digital pin 22
const int cathode = 54;       // Analog pin 0
const int p = 250;

void setup() {
  analogReadResolution(12);
  pinMode(anode, OUTPUT);
  pinMode(cathode, OUTPUT);
  Serial.begin(115200);   
}

void loop() {
  
  // Led OFF
  digitalWrite(anode, LOW);
  digitalWrite(cathode, LOW);
  delay(p);
  
  // Reverse Charge
  digitalWrite(anode, LOW);
  digitalWrite(cathode, HIGH);
  
  // Measure
  pinMode(cathode, INPUT);
  delay(20);
  int val = analogRead(0);    //--> THIS is the culprit (!)
  
  // report
  Serial.print("analogRead: ");
  Serial.println(val,DEC);
  
  // Led ON
  //## --> DOES'T WORK ON 1.5.6-r2(!) The LED remains 'off' and never blinks ON again!
  //## --> Works fine on 1.5.4, blinks -as expected.
  pinMode(cathode, OUTPUT);
  digitalWrite(anode, HIGH);
  digitalWrite(cathode, LOW);
  delay(p);
}
@agdl agdl added the Type: Duplicate Another item already exists for this topic label Dec 5, 2014
@agdl
Copy link
Member

agdl commented Dec 5, 2014

@DenDanny please see #2198

@agdl agdl closed this as completed Dec 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Duplicate Another item already exists for this topic
Projects
None yet
Development

No branches or pull requests

2 participants