7-seg Display

A life-size 7-segment display visualizes the output of 2 artificial nueral networks


Key concepts/tech used: Arduino, p5.js, serial communication | In collaboration with: Mikian Musser

The Idea

My friend, Mikian, created an artificial neural network to recognize hand-written digits from the MNIST dataset. We thought it would be cool to visualize what the neural network outputs on a real-life seven segment.

Visual representation of Mikian's neural network

Building the 7-seg

Communicating Through Serial

The p5.js serialport library was used to communicate between p5 program and Arduino. It works as follows:


Since we were sending in 1 second intervals, the serial port was sometimes filled with random information. To prevent this from affecting our visualization, we performed a simple error check only accepting input if they're between 0-9

setInterval(
    function(){
      console.log(numSent);
      serial.write((numSent)+"");
    }
    ,1000);
}
                    
incomingByte = Serial.read();
incomingByte = incomingByte - '0';
delay(100);

if (incomingByte <= 9 && incomingByte>= 0) {
    setNum(incomingByte);
}
                    

Sending and recieving in p5.js and Arduino

Encoding the data

int BCDToSS[16][7] = {
  {1,0,0,1,0,0,1}, // 0
  {0,0,0,0,1,1,1}, // 1
  {1,0,1,1,0,1,0}, // 2
  {1,0,0,1,1,1,0}, // 3
  {0,0,0,0,1,0,0}, // 4
  {1,1,0,1,1,0,0}, // 5
  {1,1,0,1,0,0,0}, // 6
  {1,0,0,0,1,1,1}, // 7
  {1,0,0,1,0,0,0}, // 8
  {1,0,0,1,1,0,0}, // 9
  {1,0,0,0,0,0,0}, // A
  {0,1,0,1,0,0,0}, // B
  {1,1,1,1,0,0,1}, // C
  {0,0,0,1,0,1,0}, // D
  {1,1,1,1,0,0,0}, // E
  {1,1,1,0,0,0,0}  // F
};
                    

A basic decimal to binary-coded decimal encoder was used to translate the integer recieved by the Arduino into either on or off commands for each of the 7 servos. As a result, we could loop through 0-F.

Visualizing Neural Networks

We tested the final hardware on 2 different neural networks!