The original idea this week was to create a simple circuit board that could detect different types of chess pieces. By placing stickers of different colors at the bottom of different types of chess pieces, using an Ir emitter to illuminate the bottom of the chess pieces, and receiving the reflected values through an Ir photo sensor. Due to the different colors of stickers at the bottom of different chess pieces, the Ir photo sensor received different values when sensing different chess pieces, From this, different types of chess pieces can be distinguished, and the data results can be fed back to the microcontroller for later application of different code programs based on different types of chess pieces. Determine the numerical range corresponding to the bottom stickers of each type of chess piece through repeated experiments, and define the numerical range corresponding to different types of chess pieces in Arduino, and display the detected chess piece types through the Serial Monitor.

The original idea this week was to create a simple circuit board that could detect different types of chess pieces. By placing stickers of different colors at the bottom of different types of chess pieces, using an Ir emitter to illuminate the bottom of the chess pieces, and receiving the reflected values through an Ir photo sensor. Due to the different colors of stickers at the bottom of different chess pieces, the Ir photo sensor received different values when sensing different chess pieces, From this, different types of chess pieces can be distinguished, and the data results can be fed back to the microcontroller for later application of different code programs based on different types of chess pieces. Determine the numerical range corresponding to the bottom stickers of each type of chess piece through repeated experiments, and define the numerical range corresponding to different types of chess pieces in Arduino, and display the detected chess piece types through the Serial Monitor.

The original idea this week was to create a simple circuit board that could detect different types of chess pieces. By placing stickers of different colors at the bottom of different types of chess pieces, using an Ir emitter to illuminate the bottom of the chess pieces, and receiving the reflected values through an Ir photo sensor. Due to the different colors of stickers at the bottom of different chess pieces, the Ir photo sensor received different values when sensing different chess pieces, From this, different types of chess pieces can be distinguished, and the data results can be fed back to the microcontroller for later application of different code programs based on different types of chess pieces. Determine the numerical range corresponding to the bottom stickers of each type of chess piece through repeated experiments, and define the numerical range corresponding to different types of chess pieces in Arduino, and display the detected chess piece types through the Serial Monitor.

The original idea this week was to create a simple circuit board that could detect different types of chess pieces. By placing stickers of different colors at the bottom of different types of chess pieces, using an Ir emitter to illuminate the bottom of the chess pieces, and receiving the reflected values through an Ir photo sensor. Due to the different colors of stickers at the bottom of different chess pieces, the Ir photo sensor received different values when sensing different chess pieces, From this, different types of chess pieces can be distinguished, and the data results can be fed back to the microcontroller for later application of different code programs based on different types of chess pieces. Determine the numerical range corresponding to the bottom stickers of each type of chess piece through repeated experiments, and define the numerical range corresponding to different types of chess pieces in Arduino, and display the detected chess piece types through the Serial Monitor.


                    const int sensorPin = A0;

                    void setup() {
                    pinMode(sensorPin, INPUT);  // sets the sensor pin as input;
                    Serial.begin(9600);
                    }

                    void loop() {
                    int sensorValue = analogRead(sensorPin);
                    Serial.println(sensorValue);

                    if (300 < sensorValue && sensorValue < 500) {
                        Serial.println("Piece Type: King");
                    } else if (200 < sensorValue && sensorValue < 300) {
                        Serial.println("Piece Type: Queen");
                    } else if (800 < sensorValue && sensorValue < 900) {
                        Serial.println("Piece Type: Rook");
                    } else if ( 700 < sensorValue && sensorValue < 800) {
                        Serial.println("Piece Type: Bishop");
                    } else if ( 950 < sensorValue && sensorValue < 962) {
                        Serial.println("Piece Type: Knight");
                    } else if (962 < sensorValue && sensorValue < 970) {
                        Serial.println("Piece Type: Pawn");
                    } else {
                        Serial.println("Color Detected: Unknown");
                    }
                    delay(500);
                    // put your main code here, to run repeatedly:

                    }