I got a new spark core and my A0- A7 pins, when used as INPUT always display 4095 no matter what is connected to pins.
I have even tried connecting A pins to GND, still 4095. My code is as follows:
int a, b, c, d, e, f, g, h;
I am programming my core over USB. All my other functions work great, Analog port works fine for output but the input is ALWAYS 4095.
Please help me out here.
I’m not sure if this could be a timing thing, but just to exclude this from the list of posdible causes, try to put the respective
Serial.println() statements and a very brief delay between each
And just for test purposes try to set the
pinMode(A0, INPUT_PULLDOWN) to see if you at least then get a zero reading.
And another blind shot, could you try to flash your test sketch via the WebIDE, too? (Don’t forget to comment out the
#include "application.h" for it)
Thank you for your reply, I tried it and still no luck.
Tried with pinMode as INPUT_PULLDOWN still it displays 4095
Also tried with delay, even for single pin it gives the same result.
Also tried with WebID.
Is my port damaged by any means? I am sure I did not hook it up to any 5 V sensor. The port works well as output with analogWrite.
This doesn’t sound good - but not all is lost yet
Could you try to do a factory reset - which will reflash Tinker firmware - and then test your pins with the Tinker App?
Just use the bare Core with nothing attached but power and then do some Tinker analogRead AND digitalRead.
The analogRead should give you random readings, since the pins are floating and most digitalReads should give you LOW (at least on my Core this is the case).
Since not all the analog pins share the same GPIO port, I’d not necessarily assume that all pins would be dead even if you had blown one pin.
I’m remembering an analog reading thread from a while back, I think the default ADC read mode can cause a little interaction with other analog readings when done very frequently. What happens when you read just one of the pins? And can you try outputting the values with something like
Serial.println(String(e)); just to make sure it’s not a casting / conversion error?
And you might need to ground those pins, or the core. Maybe try changing your power supply / usb cable, or removing the core from the breadboard?
Tried this as well. Tinker by factory reset, it shows 4095 on my iPad too. Just once some pin A5 arbitrarily flashes 0 or 2047 (no other values other than these). I checked if there is any short circuit using a multimeter, it looks all good. changed the USB cable, new code:
int a, b, c, d, e, f, g, h;
Also unplugged from breadboard, connected the analog input to ground.
Still the same.
This is quite weird, isn’t it?
Folks, the analog pins cannot be set for “INPUT” in the regular way since they require “special” treatment. In the analogRead() function, pinMode is called:
Try without doing any pinMode settings. I am not sure why Tinker would give you readings you got but give it a shot anyway.
Darn, @peekay123 is right with the
pinMode() - totally missed that.
But it still shouldn’t cause any troubles if you do, since
analogRead() would set wrong
pinMode() right implicitly anyway.
And Tinker App does not do any wrong
pinMode() setting either.
So there must still be something fishy here.
Also tried un commenting the pinMode here, I have uploaded my code and serial output as well.
Now I am actually curious as why I am getting this error rather than getting it fixed
Thank you Spark community for all your helpful suggestions.
Also tried grounding the pin A7, as well as floating it.
Hello, I still need some help here. I tried every possible thing but am still out of luck.
You see me out of options - so I’d guess you’ve got a hardware issue.
Especially if all your A pins behave that way.
Maybe @Dave has got some other suggestions.
@sid drop us a line at firstname.lastname@example.org referencing this post and we’ll see if a replacement can be sent.
Note, have you tried using the analog input pins as digital inputs? If so, what happens?
Thank you, I will definitely drop a line.
Yes, I have tried them using digital input. It always shows the same value. When connected to ground 4095
When connected to 3.3V of spark core via a resistor - still the same.
When using the pins as output, they work fine.
analogWrite(A0,0) - no buzz ( Buzzer is connected to A0)
analogWrite(A0,50) - little buzz
analogWrite(A0,150) - bit more buzz
analogWrite(A0,200) - loud one.
It works fine with all outputs, but never accepts an input. All the pins A0 - A7
Yea, I agree with @harrisonjones, sounds like we should send a replacement.