/* Programmer = Devil Snare; Code = Seven Segment Display; Date = 31/07/2016; */ /* I have connected my seven segment pins of a to g on Arduino pins 2 to 8; You have to replace value of variable pin in function display to 'a' pin of your Arduino; Also you have to replace the i value in the for loop in setup function to match your pins; */ byte display[10][7] = //Multi-Dimensional Array for numbers 0 to 9 on SSD; { {1, 1, 1, 1, 1, 1, 0}, {0, 1, 1, 0, 0, 0, 0}, {1, 1, 0, 1, 1, 0, 1}, {1, 1, 1, 1, 0, 0, 1}, {0, 1, 1, 0, 0, 1, 1}, {1, 0, 1, 1, 0, 1, 1}, {1, 0, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 0, 0, 0}, {1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 1, 1, 1}, }; void display(byte digit) //Function for displaying the numbers; { byte pin = 2; //Starting pin of your connected segment 'a' on Arduino; for(byte sC = 0; sC < 7; sC++) { digitalWrite(pin, disp[digit][sC]); pin++; } } void setup() { Serial.begin(9600); //Setting up the Arduino to communicate with computer at 9600 Baudrate; for(int i = 2; i <= 8; i++) //Declaring segment pins connected from 2 to 8 as output pins; { pinMode(i, OUTPUT); } } void loop() //Checking for input from processing; { if(Serial.available() > 0) { int display = Serial.read(); display(display); //Function call to display function passing the variable display; } }