5/24/23 Optimized Code & Final Week

Hello All!

This week is technically my final week as a senior. I have to take finals soon, then prepare for graduation.

The chessboard is almost complete, it only took like 5 months to complete but it’s almost done. Mr. Christy and me looked over the code for the chessboard and Mr.Christy adjusted it to be more optimized.

#include

//TRANSISTORS ( WHAT TURNS THEM ON ) (IS THE SIGNAL PIN ON THE PCB )
#define ROW1 3
#define ROW2 4

//LIGHT SHIFT OVER #
#define SHIFT 5

//ON / OFF
#define CHESSPIECE 0
#define NOCHESSPIECE 1

// ARDUINO BOARD TO PCB
uint8_t columns[8];
uint8_t colPins[8] = {13, 12, 11, 10, 9, 8, 6, 5};

//THE LEDs
Adafruit_NeoPixel pixels(79, 7, NEO_GRB + NEO_KHZ800);

void piece_color(uint8_t start, int piece) {
for (int i = start; i < start + 5; i++) {
if (piece == true) {
pixels.setPixelColor(i, pixels.Color(125, 0, 0));
}
else {
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
}
}
}

void setup() {
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)

for (int i = 0; i < 8; i++) {
pinMode(colPins[i], INPUT_PULLUP);
}

// pinMode(five[6], OUTPUT);
pinMode(ROW1, OUTPUT);
pinMode(ROW2, OUTPUT);

// put your setup code here, to run once:
Serial.begin(19200);
}

void loop() {

digitalWrite (ROW1, HIGH);

delayMicroseconds(80);

// WHEN HALL EFFECT SENSOR DETECT, TURN LEDS ON
for (int i = 0; i < 8; i++) {
columns[i] = digitalRead(colPins[i]);
Serial.print(columns[i]);
if (columns[i] == CHESSPIECE) {
piece_color(i * 5, true);
} else {
piece_color(i * 5, false);
}

}
pixels.show();
Serial.println();
delay(300);

I made new PCBs, and connected them to the headers. It worked but, I found out that there is something strange going on at the end of the row. the lights are already on and they aren’t supposed to do that.

I am currently going through the PCB designs trying to fix this issue.

Leave a comment