vencinachev

Tester-Fail

Jan 13th, 2026
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. const int A_PIN = 13;   // вход A
  2. const int B_PIN = 12;   // вход B
  3. const int C_PIN = 11;   // вход C
  4. const int D_PIN = 10;   // вход D
  5. const int Y_PIN = 9;    // изход Y
  6. const int LED_OK  = 2;
  7. const int LED_NOK = 3;
  8.  
  9. struct Vec {
  10.   uint8_t a;
  11.   uint8_t b;
  12.   uint8_t c;
  13.   uint8_t d;
  14.   uint8_t expected;
  15. };
  16.  
  17. // Тестов вектор (SA1/f)
  18. Vec testsa1_f = { 1, 1, 0, 0, 0 };
  19.  
  20. void setup() {
  21.   Serial.begin(115200);
  22.   pinMode(A_PIN, OUTPUT);
  23.   pinMode(B_PIN, OUTPUT);
  24.   pinMode(C_PIN, OUTPUT);
  25.   pinMode(D_PIN, OUTPUT);
  26.   pinMode(Y_PIN, INPUT);
  27.   pinMode(LED_OK, OUTPUT);
  28.   pinMode(LED_NOK, OUTPUT);
  29.   bool pass = true;
  30.   digitalWrite(A_PIN, testsa1_f.a);
  31.   digitalWrite(B_PIN, testsa1_f.b);
  32.   digitalWrite(C_PIN, testsa1_f.c);
  33.   digitalWrite(D_PIN, testsa1_f.d);
  34.   delayMicroseconds(10);   // време за установяване
  35.   int y = digitalRead(Y_PIN);
  36.  
  37.   if (y != testsa1_f.expected) {
  38.     pass = false;
  39.   }
  40.  
  41.   if (pass) {
  42.     Serial.println("PASS: gate OK");
  43.     digitalWrite(LED_OK, HIGH);
  44.   } else {
  45.     Serial.println("FAIL: SA1/f");
  46.     digitalWrite(LED_NOK, HIGH);
  47.   }
  48. }
  49.  
  50. void loop() {
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment