Reconcile Analog
it's known problem analog ports not return proper pin names when this:
servopin = a0;
serial.println (servopin);
this such basic problem can't believe @ level (almost no programming experience) dealing it, here am.
if above on uno, returns 14. a0-a5 (6 analog ports) 14,15,16,17,18,19.
if on mega, returns 54 start through 69 a0-a15.
this makes rather difficult tell user port supposed using analog input:
serial.print ("this controlled potentiometer @ pin ");
so, here solution. problem is, not programmer hoping can streamline code bit. following 2 pin solutions!!! since run mega, need expanded 13!! using library functions this?
servopin = a0;
serial.println (servopin);
this such basic problem can't believe @ level (almost no programming experience) dealing it, here am.
if above on uno, returns 14. a0-a5 (6 analog ports) 14,15,16,17,18,19.
if on mega, returns 54 start through 69 a0-a15.
this makes rather difficult tell user port supposed using analog input:
serial.print ("this controlled potentiometer @ pin ");
so, here solution. problem is, not programmer hoping can streamline code bit. following 2 pin solutions!!! since run mega, need expanded 13!! using library functions this?
code: [select]
void reconcileanalogpin1() {
/* how around fact analog pins not report the
* proper numbers. a0 not comes when choose example,
* analogpin1 = a0; on uno, a0 = pin 14. on mega 2560, a0 = pin 54. since
* mega has 16 analog pins , uno has 6, lets resolve issue here: */
if (analogpin1 == 54 || analogpin1 == 14){
serial.print ("a0");
}
else if (analogpin1 == 55 || analogpin1 == 15){
serial.print ("a1");
}
else if (analogpin1 == 56 || analogpin1 == 16){
serial.print ("a2");
}
else if (analogpin1 == 57 || analogpin1 == 17){
serial.print ("a3");
}
else if (analogpin1 == 58 || analogpin1 == 18){
serial.print ("a4");
}
else if (analogpin1 == 59 || analogpin1 == 19){
serial.print ("a5");
}
else if (analogpin1 == 60) {
serial.print ("a6");
}
else if (analogpin1 == 61) {
serial.print ("a7");
}
else if (analogpin1 == 62) {
serial.print ("a8");
}
else if (analogpin1 == 63) {
serial.print ("a9");
}
else if (analogpin1 == 64) {
serial.print ("a10");
}
else if (analogpin1 == 65) {
serial.print ("a11");
}
else if (analogpin1 == 66) {
serial.print ("a12");
}
else if (analogpin1 == 67) {
serial.print ("a13");
}
else if (analogpin1 == 68) {
serial.print ("a14");
}
else if (analogpin1 == 69) {
serial.print ("a15");
}
}
void reconcileanalogpin2() {
if (analogpin2 == 54 || analogpin2 == 14){
serial.print ("a0");
}
else if (analogpin2 == 55 || analogpin2 == 15){
serial.print ("a1");
}
else if (analogpin2 == 56 || analogpin2 == 16){
serial.print ("a2");
}
else if (analogpin2 == 57 || analogpin2 == 17){
serial.print ("a3");
}
else if (analogpin2 == 58 || analogpin2 == 18){
serial.print ("a4");
}
else if (analogpin2 == 59 || analogpin2 == 19){
serial.print ("a5");
}
else if (analogpin2 == 60) {
serial.print ("a6");
}
else if (analogpin2 == 61) {
serial.print ("a7");
}
else if (analogpin2 == 62) {
serial.print ("a8");
}
else if (analogpin2 == 63) {
serial.print ("a9");
}
else if (analogpin2 == 64) {
serial.print ("a10");
}
else if (analogpin2 == 65) {
serial.print ("a11");
}
else if (analogpin2 == 66) {
serial.print ("a12");
}
else if (analogpin2 == 67) {
serial.print ("a13");
}
else if (analogpin2 == 68) {
serial.print ("a14");
}
else if (analogpin2 == 69) {
serial.print ("a15");
}
}
for every board variant num_digital_pins, num_analog_inputs, analoginputtodigitalpin(p) defined. use them
Arduino Forum > Using Arduino > Programming Questions > Reconcile Analog
arduino
Comments
Post a Comment