Introduction: Arduino Digital and Analog Pin Status Check.

this is a test code to check the status of the pins on Arduino board working or not. in this test code you must give the no. of digital pin. are there on the board before starting of the program and for analog pins must enter the values after starting the program in serial monitor.

Supplies

  1. Arduino board - 1
  2. usb cable for connecting and checking.

Step 1: Digital Pin Checking

upload the below code in the Arduino controller for checking Digital pin status.

int Dp, Dpn; 

void setup() {
  Serial.begin(9600);  // Initialize serial communication
  Dpn = 13; // Total no. of Digital pins:Dpn

}


void loop() {
for (Dp = 0; Dp <= Dpn; Dp++) 
  { // Checking the digital pin status
    pinMode(Dp,INPUT);
   int Dps = digitalRead(Dp);
   Serial.print("< Digital pin :-");
    Serial.print(Dp);
    Serial.print("-");
      Serial.print(Dps);
        Serial.println("> ");
    delay(1000);
    // This process repeats until you stop the controller
    }

}

Step 2: Anolog Pin Checking

upload the below code in the Arduino controller for checking Analog pin status. and this code you must give the total pin repeated time for correct values. and this code is still need to test more.

void setup() { 
  Serial.begin(9600);  // Initialize serial communication
}


void loop() {
  char fixedAlphabet = 'A';
  int maxNumber;


  // Input the maximum number from the Serial Monitor
  Serial.println("Enter the total analog pin number:");
  while (!Serial.available()) {
    // Wait for input
  }
  maxNumber = Serial.parseInt();  // Read the integer input


  // Loop from 0 to the maximum number and print the result
  for (int i = 0; i <= maxNumber; ++i) {
    // Concatenate fixedAlphabet and i into a single string
    String combined = String(fixedAlphabet) + String(i);

    // Use the value from analogRead based on the pin specified in combined
    int analogValue = analogRead(combined.charAt(1) - '0');

    // Print the combined string and analogRead value on a new line
    Serial.print(" Analog Pin Read:- ");
    Serial.print(combined);
    Serial.print(" = ");
    Serial.println(analogValue);
    delay(1000);
  }


  delay(500); 
}


Step 3: Link for Tinkercad to See the Simulation and Code