0% found this document useful (0 votes)
11 views

Document 1

The document contains code to test for shorts between pins on an Arduino by setting each pin as an output and checking if it reads as low, then doing the same while each other pin is pulled high to check for shorts between pins.

Uploaded by

yakov katz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Document 1

The document contains code to test for shorts between pins on an Arduino by setting each pin as an output and checking if it reads as low, then doing the same while each other pin is pulled high to check for shorts between pins.

Uploaded by

yakov katz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

01 #define FIRST_PIN 0 // первый вывод

02 #define LAST_PIN 19 // последний вывод

03

04 void Test1(byte pin)

05 {

06 if(pin < 10) Serial.print(" PIN: ");

07 else Serial.print(" PIN: ");

08 Serial.print(pin);

09 pinMode(pin, OUTPUT);

10 digitalWrite(pin, 0);

11 Serial.print(" LOW: ");

12 if(!digitalRead(pin)) Serial.print("OK ");

13 else Serial.print("FAIL");

14 digitalWrite(pin, 1);

15 Serial.print(" HIGH: ");

16 if(digitalRead(pin)) Serial.print("OK ");

17 else Serial.print("FAIL");

18 pinMode(pin, INPUT);

19 Serial.print(" PULL UP: ");

20 if(digitalRead(pin)) Serial.print("OK ");

21 else Serial.print("FAIL");

22 digitalWrite(pin, 0);

23 }

24

25 void Test2(byte pin)


26 {

27 Serial.print(" ");

28 pinMode(pin, OUTPUT);

29 digitalWrite(pin, 1);

30 delay(5);

31 if(!digitalRead(pin))Serial.println("SHORT");

32 else Serial.println("OK");

33 pinMode(pin, INPUT);

34 digitalWrite(pin, 0);

35

36 }

37

38 void setup() {

39 Serial.begin(9600);

40

41 Serial.println("Test of short circuit on GND or VCC and between pins:");

42 Serial.println();

43 for(byte i = FIRST_PIN; i <= LAST_PIN; i++)

44 {

45 for(byte j = FIRST_PIN; j <= LAST_PIN; j++)

46 {

47 pinMode(j, INPUT);

48 digitalWrite(j, 0);

49 }

50 Test1(i);
51

52 for(byte j = FIRST_PIN; j <= LAST_PIN; j++)

53 {

54 pinMode(j, OUTPUT);

55 digitalWrite(j, 0);

56 }

57 Test2(i);

58 }

59

60 for(byte j = FIRST_PIN; j <= LAST_PIN; j++)

61 {

62

pinMode(j, INPUT);

63 digitalWrite(j, 0);

64 }

65 }

66

67 void loop() {}

You might also like