TheTNR
Published © GPL3+

Smart Chessboard - Reed Switch System

It will show you the ways the pawn can move. Or if you move with Knight, it will draw you an "L". So you will never forget

AdvancedFull instructions provided10
Smart Chessboard - Reed Switch System

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
Reed Switch, SPST-NO
Reed Switch, SPST-NO
×1
WS2812 Addressable LED Strip
Digilent WS2812 Addressable LED Strip
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
PCB Holder, Soldering Iron
PCB Holder, Soldering Iron

Story

Read more

Schematics

Elektronic Circuit

Code

Arduino code

Arduino
#include <FastLED.h>


#define NUM_LEDS 64

#define DATA_PIN 10

 byte i=0;

CRGB leds[NUM_LEDS];
void setup()
{
 
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
 
  for(byte i=2;i<10;i++)
  {
  pinMode(i, OUTPUT);
  }
  for(byte i=14;i<22;i++)
  {
  pinMode(i, INPUT);
  }
 
}

void loop()
{
   for(byte i=0;i<64;i++)
  {
  leds[i] = CRGB::White;
  FastLED.show();
 
  }
 
  digitalWrite(2,HIGH);
  digitalWrite(3,LOW);
  digitalWrite(4,LOW);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
  digitalWrite(8,LOW);
  digitalWrite(9,LOW);
 
   if(digitalRead(14)==HIGH)
  {
   i=0;
  }
   if(digitalRead(15)==HIGH)
  {
    i=1;
  }
   if(digitalRead(16)==HIGH)
  {
    i=2;
  }
  if(digitalRead(17)==HIGH)
  {
    i=3;
  }
  if(digitalRead(18)==HIGH)
  {
    i=4;
  }
  if(digitalRead(19)==HIGH)
  {
    i=5;
  }
  if(digitalRead(20)==HIGH)
  {
    i=6;
  }
  if(digitalRead(21)==HIGH)
  {
    i=7;
  }
 digitalWrite(2,LOW);
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
  digitalWrite(8,LOW);
  digitalWrite(9,LOW);
 
   if(digitalRead(14)==HIGH)
  {
   i=16;
  }
   if(digitalRead(15)==HIGH)
  {
    i=17;
  }
   if(digitalRead(16)==HIGH)
  {
    i=18;
  }
  if(digitalRead(17)==HIGH)
  {
    i=19;
  }
  if(digitalRead(18)==HIGH)
  {
    i=20;
  }
  if(digitalRead(19)==HIGH)
  {
    i=21;
  }
  if(digitalRead(20)==HIGH)
  {
    i=22;
  }
  if(digitalRead(21)==HIGH)
  {
    i=23;
  }




 
    leds[i] = CRGB::Red;
  FastLED.show();
  delay(500);
 
  leds[i] = CRGB::Black;
  FastLED.show();
  delay(500);
   
 
 
   
 
}

Credits

TheTNR

TheTNR

5 projects • 111 followers
A teacher at high school. I am an electronics teacher.

Comments

Add projectSign up / Login