Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int A_PIN = 13; // вход A
- const int B_PIN = 12; // вход B
- const int C_PIN = 11; // вход C
- const int D_PIN = 10; // вход D
- const int Y_PIN = 9; // изход Y
- const int LED_OK = 2;
- const int LED_NOK = 3;
- struct Vec {
- uint8_t a;
- uint8_t b;
- uint8_t c;
- uint8_t d;
- uint8_t expected;
- };
- // Тестов вектор (SA1/f)
- Vec testsa1_f = { 1, 1, 0, 0, 0 };
- void setup() {
- Serial.begin(115200);
- pinMode(A_PIN, OUTPUT);
- pinMode(B_PIN, OUTPUT);
- pinMode(C_PIN, OUTPUT);
- pinMode(D_PIN, OUTPUT);
- pinMode(Y_PIN, INPUT);
- pinMode(LED_OK, OUTPUT);
- pinMode(LED_NOK, OUTPUT);
- bool pass = true;
- digitalWrite(A_PIN, testsa1_f.a);
- digitalWrite(B_PIN, testsa1_f.b);
- digitalWrite(C_PIN, testsa1_f.c);
- digitalWrite(D_PIN, testsa1_f.d);
- delayMicroseconds(10); // време за установяване
- int y = digitalRead(Y_PIN);
- if (y != testsa1_f.expected) {
- pass = false;
- }
- if (pass) {
- Serial.println("PASS: gate OK");
- digitalWrite(LED_OK, HIGH);
- } else {
- Serial.println("FAIL: SA1/f");
- digitalWrite(LED_NOK, HIGH);
- }
- }
- void loop() {
- }
Advertisement
Add Comment
Please, Sign In to add comment