chipKIT® Development Platform

Inspired by Arduino™

Writing code that works on both 3.3 and 5v referenced ADC.

Created Fri, 04 Nov 2011 02:45:19 +0000 by drBart


drBart

Fri, 04 Nov 2011 02:45:19 +0000

I have both an Arduino Uno board, and a Max32. I'd like to have one set of code that works on both boards without any modifications. I know that for the Max32, the peripheral libraries are defined, so I thought the following code would work, however it does not, and only the code in the #else section gets compiled. Any suggestions?

#ifdef PowerSaveIdle
  //convert to voltage on 3.3v scale
  Serial.println("Chipkit");
  temperature *= 0.00322580645;
#else
  //convert voltage on 5.0v scale
  Serial.println("Arduino");
  temperature *= 0.00488758553;
#endif

Jacob Christ

Sun, 13 Nov 2011 22:41:27 +0000

How about this?

#if  defined(__PIC32MX__)
  //convert to voltage on 3.3v scale
  Serial.println("Chipkit");
  temperature *= 0.00322580645;
#else
  //convert voltage on 5.0v scale
  Serial.println("Arduino");
  temperature *= 0.00488758553;
#endif

Jacob


drBart

Tue, 15 Nov 2011 09:00:56 +0000

Thank you.