Advertisement
ScienceGeyser

PinTest01

Jul 4th, 2021 (edited)
1,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.     This can be used to test for cooked pins on an Arduino
  3.     Change OUTPUT states then Change to INPUT and Write HIGH (pull-ups on) and then LOW (pull-ups off)
  4.     Start with pin 2 and work up to pin 12 one at a time. We'll assume the other pins are fine.
  5.     Verify the voltage on each pin with a DVM.
  6. */
  7.  
  8. int testPin=2; // Start with pin 2 and increment for each pin after running the four tests below.
  9. int testNumber=0; // Start at 0 and increment to 3 on each pin set above.
  10.  
  11. void setup() {
  12.   // initialize digital pin LED_BUILTIN as an output.
  13.   pinMode(LED_BUILTIN, OUTPUT);
  14.  
  15.   switch(testNumber){
  16.     case 0:
  17.      pinMode(testPin,OUTPUT);
  18.      digitalWrite(testPin,LOW);
  19.      break;
  20.     case 1:
  21.      pinMode(testPin,OUTPUT);
  22.      digitalWrite(testPin,HIGH);
  23.      break;
  24.     case 2:
  25.      pinMode(testPin,INPUT);
  26.      digitalWrite(testPin,HIGH);
  27.      break;
  28.     case 3:
  29.      pinMode(testPin,INPUT);
  30.      digitalWrite(testPin,LOW);
  31.      break;
  32.     default:
  33.      pinMode(testPin,INPUT);
  34.      digitalWrite(testPin,LOW);
  35.      break;
  36.    
  37.   }
  38. }
  39.  
  40. // the loop function runs over and over again forever
  41. void loop() {
  42.   digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  43.   delay(1000);                       // wait for a second
  44.   digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  45.   delay(1000);                       // wait for a second
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement