- /*
- Blink
- Turns on an LED on for one second, then off for one second, repeatedly.
- Most Arduinos have an on-board LED you can control. On the Uno and
- Leonardo, it is attached to digital pin 13. If you're unsure what
- pin the on-board LED is connected to on your Arduino model, check
- the documentation at http://www.arduino.cc
- This example code is in the public domain.
- modified 8 May 2014
- by Scott Fitzgerald
- */
- int pi[21] = {3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6};
- void printSegment(int number) {
- digitalWrite(number, LOW);
- }
- void printDigit(int number) {
- if (number == 0) {
- printSegment(3);
- printSegment(4);
- printSegment(5);
- printSegment(7);
- printSegment(8);
- printSegment(9);
- }
- if (number == 1) {
- printSegment(3);
- printSegment(9);
- }
- if (number == 2) {
- printSegment(4);
- printSegment(5);
- printSegment(6);
- printSegment(9);
- printSegment(8);
- }
- if (number == 3) {
- printSegment(4);
- printSegment(3);
- printSegment(6);
- printSegment(9);
- printSegment(8);
- }
- if (number == 4) {
- printSegment(7);
- printSegment(6);
- printSegment(9);
- printSegment(3);
- }
- if (number == 5) {
- printSegment(8);
- printSegment(7);
- printSegment(6);
- printSegment(3);
- printSegment(4);
- }
- if (number == 6) {
- printSegment(8);
- printSegment(7);
- printSegment(6);
- printSegment(3);
- printSegment(4);
- printSegment(5);
- }
- if (number == 7) {
- printSegment(3);
- printSegment(9);
- printSegment(8);
- }
- if (number == 8) {
- printSegment(8);
- printSegment(7);
- printSegment(6);
- printSegment(3);
- printSegment(4);
- printSegment(5);
- printSegment(9);
- }
- if (number == 9) {
- printSegment(8);
- printSegment(7);
- printSegment(6);
- printSegment(3);
- printSegment(4);
- printSegment(9);
- }
- }
- void resetDisplay() {
- for (int i = 2; i < 10; i++) {
- digitalWrite(i, HIGH);
- }
- }
- // the setup function runs once when you press reset or power the board
- void setup() {
- // initialize digital pin 13 as an output.
- for (int i = 2; i < 10; i++) {
- pinMode(i, OUTPUT);
- digitalWrite(i, HIGH);
- }
- }
- // the loop function runs over and over again forever
- void loop() {
- for (int k = 0; k < 21; k++) {
- resetDisplay();
- printDigit(pi[k]);
- delay(1000);
- }
- //printDigit(0);
- //digitalWrite(6, HIGH);
- //digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
- //delay(1000); // wait for a second
- //digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
- //delay(1000); // wait for a second
- }
- //Unused code
- /*
- int pi[21] = {3,1,4,1,5,9,2,6,5,3,5,8,9,7,9,3,2,3,8,4,6};
- /*
- for (int j = 0; j < 10; j++) {
- resetDisplay();
- printDigit(j);
- delay(1000);
- }
- */
- /*
- for (int k = 0; k < 21; k++) {
- resetDisplay();
- printDigit(pi[k]);
- delay(1000);
- }
- */
- //printDigit(0);
- //digitalWrite(6, HIGH);
- //digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
- //delay(1000); // wait for a second
- //digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
- //delay(1000); // wait for a second
- */