tester pins A0 A1 A2...?

art100
Offline
Зарегистрирован: 09.03.2014
//art100 20140616 tester pins ardunio mega adk
int d=2;
int m=2;

void setup() {
  for(d=2; d<=12; d++){ pinMode(d, INPUT_PULLUP);  }
  for(m=13; m<=49; m++){ pinMode(m, INPUT_PULLUP);  }
//  for(int a=0, a<15; a++){ ?????????
   pinMode(A0, INPUT_PULLUP); 
   pinMode(A1, INPUT_PULLUP); 
   pinMode(A2, INPUT_PULLUP); 
   pinMode(A3, INPUT_PULLUP); 
   pinMode(A4, INPUT_PULLUP); 
   pinMode(A5, INPUT_PULLUP); 
//}
  Serial.begin(9600);
}
//========================================================================
void loop(){
 for(d=2; d<=12; d++){
  if( digitalRead(d)==LOW ){ 
   Serial.println(d); 
  }
 }
 for(m=13; m<=49; m++){
  if( digitalRead(m)==LOW ){ 
   Serial.println(m); 
  }
 } 
// for(int a=0, a<15; a++){ 
  if( digitalRead(A0)==LOW ){ Serial.println(A0); }
// }
 delay(100);
}
//========================================================================

кто-нибудь помнит перебор аналоговых пинов как обьявление ?

 

art100
Offline
Зарегистрирован: 09.03.2014

да все так

все ножки вроде целые

//art100 20140616 tester pins ardunio mega adk
int d=2;
int m=13;
int a=0;
int b=51;
//pin 22 23 usb
void setup() {
  for(d= 2; d<=12; d++){ pinMode(d, INPUT_PULLUP);  }//uno
  for(m=13; m<=49; m++){ pinMode(m, INPUT_PULLUP);  }//mega
  for(a=54; a<=60; a++){ pinMode(a, INPUT_PULLUP);  }//uno
  for(b=61; b<=69; b++){ pinMode(b, INPUT_PULLUP);  }//mega
  Serial.begin(9600);
}
//========================================================================
void loop(){
 for(d=2; d<=12; d++){//uno
  if( digitalRead(d)==LOW ){ 
   Serial.println(d); 
  }
 }
 for(m=13; m<=49; m++){//mega
  if( digitalRead(m)==LOW ){ 
   Serial.println(m); 
  }
 } 
 for(a=54; a<=60; a++){//uno
  if( digitalRead(a)==LOW ){ 
   Serial.println(a); 
  }
 }
 for(b=61; b<=69; b++){//mega
  if( digitalRead(b)==LOW ){ 
   Serial.println(b); 
  }
 } 
 delay(100);
}
//========================================================================

 

чудо тестер

архисложная схема 

 

kisoft
kisoft аватар
Offline
Зарегистрирован: 13.11.2012

Для arduino mega, pins_arduino.h:

#define NUM_DIGITAL_PINS            70
#define NUM_ANALOG_INPUTS           16
#define analogInputToDigitalPin(p)  ((p < 16) ? (p) + 54 : -1)
#define digitalPinHasPWM(p)         (((p) >= 2 && (p) <= 13) || ((p) >= 44 && (p)<= 46))

static const uint8_t SS   = 53;
static const uint8_t MOSI = 51;
static const uint8_t MISO = 50;
static const uint8_t SCK  = 52;

static const uint8_t SDA = 20;
static const uint8_t SCL = 21;
static const uint8_t LED_BUILTIN = 13;

static const uint8_t A0 = 54;
static const uint8_t A1 = 55;
static const uint8_t A2 = 56;
static const uint8_t A3 = 57;
static const uint8_t A4 = 58;
static const uint8_t A5 = 59;
static const uint8_t A6 = 60;
static const uint8_t A7 = 61;
static const uint8_t A8 = 62;
static const uint8_t A9 = 63;
static const uint8_t A10 = 64;
static const uint8_t A11 = 65;
static const uint8_t A12 = 66;
static const uint8_t A13 = 67;
static const uint8_t A14 = 68;
static const uint8_t A15 = 69;

Для arduino uno, pins_arduino.h:

#define NUM_DIGITAL_PINS            20
#define NUM_ANALOG_INPUTS           6
#define analogInputToDigitalPin(p)  ((p < 6) ? (p) + 14 : -1)

#if defined(__AVR_ATmega8__)
#define digitalPinHasPWM(p)         ((p) == 9 || (p) == 10 || (p) == 11)
#else
#define digitalPinHasPWM(p)         ((p) == 3 || (p) == 5 || (p) == 6 || (p) == 9 || (p) == 10 || (p) == 11)
#endif

static const uint8_t SS   = 10;
static const uint8_t MOSI = 11;
static const uint8_t MISO = 12;
static const uint8_t SCK  = 13;

static const uint8_t SDA = 18;
static const uint8_t SCL = 19;
static const uint8_t LED_BUILTIN = 13;

static const uint8_t A0 = 14;
static const uint8_t A1 = 15;
static const uint8_t A2 = 16;
static const uint8_t A3 = 17;
static const uint8_t A4 = 18;
static const uint8_t A5 = 19;
static const uint8_t A6 = 20;
static const uint8_t A7 = 21;

Всё легко завернуть в цикл, разумеется с перекомпиляцией для нужного ардуино.