If you have been practicing your programming techniques and have worked through the examples, You should be able to program the sequences yourself. Note that I have used the switch layout as done in the previous Switch Example which should make life easier for you. I encourage you to have a go at the programming yourself but if you are struggling a little I have provided a working example shown below:int switchState = 0;void setup() { // initialize digital pin LED_BUILTIN as an output. pinMode(2, OUTPUT); pinMode(3, OUTPUT); pinMode(4, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, INPUT); switchState = digitalRead(9); }// the loop function runs over and over again forevervoid loop() {switchState = digitalRead(9); if (switchState == HIGH){ One(); Two(); Three(); Four (); Five(); Six(); Seven(); Eight(); Nine(); Zero(); }else { Zero(); } }void Zero(){ digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(2, LOW); // turn the LED off by making the voltage LOW digitalWrite(3, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(6, LOW); // turn the LED off by making the voltage LOW digitalWrite(7, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void One() { digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED off by making the voltage LOW delay(250); // wait for a second digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Two() { digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(6, LOW); // turn the LED off by making the voltage LOW digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(8, LOW); // turn the LED off by making the voltage LOW digitalWrite(2, LOW); // turn the LED off by making the voltage LOW digitalWrite(3, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Three() { digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(3, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(6, LOW); // turn the LED off by making the voltage LOW digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Four() { digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(4, LOW); // turn the LED off by making the voltage LOW digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(7, LOW); // turn the LED off by making the voltage LOW digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Five() { digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(6, LOW); // turn the LED off by making the voltage LOW digitalWrite(7, LOW); // turn the LED off by making the voltage LOW digitalWrite(8, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW digitalWrite(3, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Six() { digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(7, LOW); // turn the LED off by making the voltage LOW digitalWrite(2, LOW); // turn the LED off by making the voltage LOW digitalWrite(3, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Seven() { digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(6, LOW); // turn the LED off by making the voltage LOW digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Eight() { digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(2, LOW); // turn the LED off by making the voltage LOW digitalWrite(3, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(6, LOW); // turn the LED off by making the voltage LOW digitalWrite(7, LOW); // turn the LED off by making the voltage LOW digitalWrite(8, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } void Nine() { digitalWrite(6, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(7, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(8, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(5, HIGH); // turn the LED on (HIGH is the voltage level) digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level) delay(250); // wait for a second digitalWrite(6, LOW); // turn the LED off by making the voltage LOW digitalWrite(7, LOW); // turn the LED off by making the voltage LOW digitalWrite(8, LOW); // turn the LED off by making the voltage LOW digitalWrite(5, LOW); // turn the LED off by making the voltage LOW digitalWrite(4, LOW); // turn the LED off by making the voltage LOW delay(250); // wait for a second } The program should allow the 7 Segment Display to count up once the switch is pressed.
See if you can modify the program to count up on each switch press.
Could you add a second 7 Segment display to count up to 20?