The matrix is working and we can visualize it
This commit is contained in:
+35
-9
@@ -7,7 +7,6 @@
|
||||
#include <Arduino.h>
|
||||
#include "595n.h"
|
||||
#include "165.h"
|
||||
// #include "Wire.h"
|
||||
|
||||
// NOTES - 595N
|
||||
// On the board, the first output pin on the SR595 is Qb
|
||||
@@ -17,17 +16,35 @@
|
||||
#define IN_CLOCK_PIN 6 // SRCLK - pin11 (Clock Pin)
|
||||
/*
|
||||
+-- --+
|
||||
|P5 P4 P3 P2 P1 P0|
|
||||
|P0 P1 P2 P3 P4 P5|
|
||||
+-----------------+
|
||||
P0 0b00000010
|
||||
P1
|
||||
*/
|
||||
#define IN_P0 0b01000000
|
||||
#define IN_P1 0b00100000
|
||||
#define IN_P2 0b00010000
|
||||
#define IN_P3 0b00001000
|
||||
#define IN_P4 0b00000100
|
||||
#define IN_P5 0b00000010
|
||||
uint8_t rows[] = {IN_P0, IN_P1, IN_P2, IN_P3, IN_P4, IN_P5};
|
||||
size_t num_rows = sizeof(rows) / sizeof(rows[0]);
|
||||
|
||||
// NOTES - 165
|
||||
#define OUT_PARALLEL_LOAD_IN 10 // PL - pin1 (Async Parallel Load In)
|
||||
#define OUT_CLOCK_IN 9 // CP - pin2 (Clock In)
|
||||
#define OUT_COMPLEMENTARY_OUT 8 // Q7 - pin7 (Complementary Output)
|
||||
#define OUT_CLOCK_ENABLE 7 // CE - pin15 (Clock Enable)
|
||||
/*
|
||||
+-- --+
|
||||
|P4 P3 P2 P1 P0|
|
||||
+--------------+
|
||||
*/
|
||||
#define OUT_P0 0b11111110
|
||||
#define OUT_P1 0b11111101
|
||||
#define OUT_P2 0b11111011
|
||||
#define OUT_P3 0b11110111
|
||||
#define OUT_P4 0b11101111
|
||||
uint8_t cols[] = {OUT_P0, OUT_P1, OUT_P2, OUT_P3, OUT_P4};
|
||||
size_t num_cols = sizeof(cols) / sizeof(cols[0]);
|
||||
|
||||
SR595N input = NewSR595N(IN_SERIAL_PIN, IN_LATCH_PIN, IN_CLOCK_PIN);
|
||||
SR165 output = NewSR165(OUT_PARALLEL_LOAD_IN, OUT_CLOCK_ENABLE,
|
||||
@@ -35,14 +52,23 @@ SR165 output = NewSR165(OUT_PARALLEL_LOAD_IN, OUT_CLOCK_ENABLE,
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
SR595N_write(&input, 0b10101010);
|
||||
SR595N_write(&input, 0b00000100);
|
||||
}
|
||||
|
||||
void loop(void) {
|
||||
delay(200);
|
||||
uint8_t scanResults[num_rows];
|
||||
|
||||
byte srOutput = SR165_read(&output);
|
||||
for (size_t row = 0; row < num_rows ; row++) {
|
||||
SR595N_write(&input, rows[row]);
|
||||
delayMicroseconds(5);
|
||||
|
||||
scanResults[row] = SR165_read(&output);
|
||||
}
|
||||
|
||||
for(size_t row = 0; row < num_rows; row++) {
|
||||
Serial.println(scanResults[row], BIN);
|
||||
}
|
||||
// Serial.println(SR165_read(&output), BIN);
|
||||
|
||||
Serial.println(srOutput, BIN);
|
||||
delay(5);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user