// Filename = 7segTEST2.ino // Sequences through the seven-segment display numbers // 0 through 9 and decimal point // Common Anode Display: LED Segments turn ON when LOW // AVOID USING PINS 0 and 1 to avoid upload challenges! int aSeg = 2; int bSeg = 3; int cSeg = 4; int dSeg = 5; int eSeg = 6; int fSeg = 7; int gSeg = 8; int dpSeg = 9; void setup ( ) { //set up digital I/O for pins 1 through 8 as OUTPUTs for (int i=2; i<10; i++) { pinMode (i, OUTPUT); } /* The above “for” code sets up the seven segment and decimal point pins and also creates each of the Uno digital I/O pins, 1 through 8, as OUTPUTs */ // With pins set up, turn the display ON and then OFF. // We can use the same pin ‘trick’ as before // to turn the segments On and OFF void loop( ) { // Realtime TEST of 7-Segment Display // TEST1: TURN ON (LOW) Number 8 plus decimal : //write digital I/O for pins 1 through 8 as LOW //add a 200 millisecond delay between write outputs for (int i=2; i<10; i++) { digitalWrite(i, LOW); delay(200); } delay(200); // TEST2: Turn OFF (HIGH) Number 8 and decimal //write digital I/O for pins 1 through 8 as HIGH for (int i=10; i>2; i--) { digitalWrite(i, HIGH); delay(200); } delay(200); }