/* 29.01.2019 Written by: Gabby Shimoni Description: This program write the modulo of the potentiometer value by 10 to 7 segment */ int num_array[10][7] = { { 1, 1, 1, 1, 1, 1, 0 }, // 0 { 0, 1, 1, 0, 0, 0, 0 }, // 1 { 1, 1, 0, 1, 1, 0, 1 }, // 2 { 1, 1, 1, 1, 0, 0, 1 }, // 3 { 0, 1, 1, 0, 0, 1, 1 }, // 4 { 1, 0, 1, 1, 0, 1, 1 }, // 5 { 1, 0, 1, 1, 1, 1, 1 }, // 6 { 1, 1, 1, 0, 0, 0, 0 }, // 7 { 1, 1, 1, 1, 1, 1, 1 }, // 8 { 1, 1, 1, 0, 0, 1, 1 } }; // 9 //function header void Num_Write(int); #define potPin A0; int potValue = 0; void setup() { // set pin modes for (int k = 2; k < 9; k++) pinMode(k, OUTPUT); } void loop() { potValue = analogRead(potPin); potValue = potValue % 10; Num_Write(potValue); delay(1000); } // this functions writes values to the sev seg pins void Num_Write(int number) { int pin = 2; for (int j = 0; j < 7; j++) { digitalWrite(pin, num_array[number][j]); pin++; } }