Created Sat, 20 Jul 2013 06:03:26 +0000 by rockier
Sat, 20 Jul 2013 06:03:26 +0000
I have this button setup and on the UNO it works fine but on the Chipkit Max 32 it does not.
I am using the example code for analogreadserial to test this button push.
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor
This example code is in the public domain.
*/
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue, DEC);
}
I have attached the pic of the button layout.
I will explain it here from 5 volt pin to a 2k resistor to 330 u resistor to 620 u resistor to 1k resistor to 3.3k resistor.
in between each resistor I have a button to ground. 5 button total. So staring between 2k and the 330u resistor is a button and so on. Also between the 2k and 330u resistor is a line back to pin A0 to read the voltage.
If I press the last button I get no change in voltage.
Sat, 20 Jul 2013 07:18:49 +0000
Use 3.3v not 5v. The pic32 is a 3.3 device, and anything over 3.3v will read as 1023.
Sat, 20 Jul 2013 19:49:10 +0000
That is the problem but I do not have the choice to pick 3.3v over 5v. This is a shield that I purchased.
Is there a way in software to fix the problem?
here is the link to it. [url]http://www.linkspritedirect.com/product_info.php?products_id=178[/url]
Sat, 20 Jul 2013 20:21:41 +0000
No, there is no way in software to fix the problem.
The ADC reads between 0 and 3.3V. Anything over 3.3V is read as 3.3V. Not only that, but it risks damaging the chip. Yes, there is a certain amount of protection, but it's never 100% foolproof.
You will have to modify the shield to use it.
Sun, 21 Jul 2013 04:16:04 +0000
Thanks for the reply.
To fix the problem I am going to change the resistor at R6 to 3.3k. This will drop the voltage down to 3.07v.
This will make the unit work and not put more than 3.3v on the A0 pin.
I may go for 4.7k to just make sure.
Thanks again.