// You should now see the 7-segment display cycle of serial number of Cadet MORETO VM
// Assign a digital pin to each segment of the display
const int a=13; // a of 7-segment attach to digital pin 13
const int b=12; // b of 7-segment attach to digital pin 12
const int c=2; // c of 7-segment attach to digital pin 2
const int d=18; // d of 7-segment attach to digital pin 18
const int e=5; // e of 7-segment attach to digital pin 5
const int f=27; // f of 7-segment attach to digital pin 27
const int g=14; // g of 7-segment attach to digital pin 14
const int dp=4; // dp of 7-segment attach to digital pin 4
void setup() {
pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);
pinMode(e, OUTPUT);
pinMode(f, OUTPUT);
pinMode(g, OUTPUT);
pinMode(dp, OUTPUT);
}
void loop() {
digital_C(); // Display C to the 7-segment
delay(1000); // Wait for 1 second
digital_dash(); // Display - to the 7-segment
delay(1000); // Wait for 1 second
digital_2(); // Display 2 to the 7-segment
delay(1000); // Wait for 1 second
digital_7(); // Display 7 to the 7-segment
delay(1000); // Wait for 1 second
digital_2(); // Display 2 to the 7-segment
delay(1000); // Wait for 1 second
digital_9(); // Display 9 to the 7-segment
delay(1000); // Wait for 1 second
digital_6(); // Display 6 to the 7-segment
delay(1000); // Wait for 1 second
}
// Display C to the 7-segment
void digital_C(void) {
digitalWrite(a,HIGH); // Turn the a of the 7-segment ON
digitalWrite(b,LOW); // Turn the b of the 7-segment OFF
digitalWrite(c,LOW); // Turn the c of the 7-segment OFF
digitalWrite(d,HIGH); // Turn the d of the 7-segment ON
digitalWrite(e,HIGH); // Turn the e of the 7-segment ON
digitalWrite(f,HIGH); // Turn the f of the 7-segment ON
digitalWrite(g,LOW); // Turn the g of the 7-segment OFF
digitalWrite(dp,LOW); // Turn the dp of the 7-segment OFF
}
// Display - to the 7-segment
void digital_dash(void) {
digitalWrite(a,LOW); // Turn the a of the 7-segment OFF
digitalWrite(b,LOW); // Turn the b of the 7-segment OFF
digitalWrite(c,LOW); // Turn the c of the 7-segment OFF
digitalWrite(d,LOW); // Turn the d of the 7-segment OFF
digitalWrite(e,LOW); // Turn the e of the 7-segment OFF
digitalWrite(f,LOW); // Turn the f of the 7-segment OFF
digitalWrite(g,HIGH); // Turn the g of the 7-segment ON
digitalWrite(dp,LOW); // Turn the dp of the 7-segment OFF
}
// Display 2 to the 7-segment
void digital_2(void) {
digitalWrite(a,HIGH); // Turn the a of the 7-segment ON
digitalWrite(b,HIGH); // Turn the b of the 7-segment ON
digitalWrite(c,LOW); // Turn the c of the 7-segment OFF
digitalWrite(d,HIGH); // Turn the d of the 7-segment ON
digitalWrite(e,HIGH); // Turn the e of the 7-segment ON
digitalWrite(f,LOW); // Turn the f of the 7-segment OFF
digitalWrite(g,HIGH); // Turn the g of the 7-segment ON
digitalWrite(dp,LOW); // Turn the dp of the 7-segment OFF
}
// Display 7 to the 7-segment
void digital_7(void) {
digitalWrite(a,HIGH); // Turn the a of the 7-segment ON
digitalWrite(b,HIGH); // Turn the b of the 7-segment ON
digitalWrite(c,HIGH); // Turn the c of the 7-segment ON
digitalWrite(d,LOW); // Turn the d of the 7-segment OFF
digitalWrite(e,LOW); // Turn the e of the 7-segment OFF
digitalWrite(f,LOW); // Turn the f of the 7-segment OFF
digitalWrite(g,LOW); // Turn the g of the 7-segment OFF
digitalWrite(dp,LOW); // Turn the dp of the 7-segment OFF
}
// Display 9 to the 7-segment
void digital_9(void) {
digitalWrite(a,HIGH); // Turn the a of the 7-segment ON
digitalWrite(b,HIGH); // Turn the b of the 7-segment ON
digitalWrite(c,HIGH); // Turn the c of the 7-segment ON
digitalWrite(d,HIGH); // Turn the d of the 7-segment ON
digitalWrite(e,LOW); // Turn the e of the 7-segment OFF
digitalWrite(f,HIGH); // Turn the f of the 7-segment ON
digitalWrite(g,HIGH); // Turn the g of the 7-segment ON
digitalWrite(dp,LOW); // Turn the dp of the 7-segment OFF
}
// Display 6 to the 7-segment
void digital_6(void) {
digitalWrite(a,HIGH); // Turn the a of the 7-segment ON
digitalWrite(b,LOW); // Turn the b of the 7-segment OFF
digitalWrite(c,HIGH); // Turn the c of the 7-segment ON
digitalWrite(d,HIGH); // Turn the d of the 7-segment ON
digitalWrite(e,HIGH); // Turn the e of the 7-segment ON
digitalWrite(f,HIGH); // Turn the f of the 7-segment ON
digitalWrite(g,HIGH); // Turn the g of the 7-segment ON
digitalWrite(dp,LOW); // Turn the dp of the 7-segment OFF
}