/* This code was written for the Stitch the Loop e-textiles curriculum by the Exploring Computer Science e-textiles team. ECS 2018 GPL V3 for non commercial use. ECS 2018 CC- BY NC SA. */ /* ◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇ This program is an EXAMPLE of the many possible solutions. This code will compile as is. ◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇◇ */ /* STUDENT META HERE STUDENT NAME(S) Date Written Brief description of what program does here. */ // The first section is where to declare global objects and call up additional files the program needs to use. /*NAMING SECTION: We name things to keep track of them easily. What will you name your other lights? */ int led1 = 0; int led2 = 3; int led3 = 10; int led4 = 6; void setup() { // The second section is for things that only need to be done once at the beginning of the program. pinMode(led1, OUTPUT); pinMode(led2, OUTPUT); pinMode(led3, OUTPUT); pinMode(led4, OUTPUT); } void loop() { /* The third section is for things that happen repeatedly in the program loop while the program is running. The code is executed in the order coded. */ cycle(); allBlink(); } // The fourth section is for functions that are called up by the third section. void cycle() { allOff(); blinkLed(led1); blinkLed(led2); blinkLed(led3); blinkLed(led4); } void allBlink() { allOn(); delay(1000); allOff(); delay(1000); } void blinkLed(int led) { on(led); delay(500); off(led); delay(500); } void allOn() { on(led1); on(led2); on(led3); on(led4); } void allOff() { off(led1); off(led2); off(led3); off(led4); } void on(int led){ digitalWrite(led, HIGH); } void off(int led) { digitalWrite(led, LOW); }