chipKIT® Development Platform

Inspired by Arduino™

ChipKit UNO32 and analogRead not working with MPIDE

Created Tue, 09 Sep 2014 01:42:54 +0000 by SuperTech-IT


Tue, 09 Sep 2014 01:42:54 +0000

I am new to the ChipKit UNO32 and I am having a noodle scratcher here.

I am using the PIC to run an RGB LED 8X8X8 cube, which is all working fine... HOWEVER - I am trying to do a simple read of an analog pin, and it always seems to be maxed out at 1024 even if I ground the pin.

The only things I have really done outside the code that runs the cube is:

pinMode (A1, INPUT);

and in the routine to read it and give me a value from 0 to 7 is

y = digitalRead(A1) / 128 //(this is inside a loop)

Y always comes back as 8 although occasionally it seems to come back with 7

No matter what I do (selecting other pins etc) when I ground the pin, this value never changes. I am baffled. Could it be the interrupt that controls the cube output doing something or what? Do I need to have specific interrupts set a certain way for the ADC to work? What am I missing? :x


Tue, 09 Sep 2014 08:33:32 +0000

I hate issues like this - you spend ages looking at it and not seeing the issue. You may find that you have more joy using analogRead() instead of digitalRead().