Can someone understand Sketch Chooser?

Hello i am not good in programming. I found the Arduino Sketch Chooser but it doesnt work for me.

I want to choose the skechtes with an IR remote control. The IR remote control ist working.

Can somebody explain me how the Sketch Chooser works maybe example sketches.

The follwing codes i want to combine.

LED effect

/*
  ***Knight rider panel***
 
  Simple code simulating knight rider's panel :)
 
  LEDs are involved in PWM pins.
 
  PWM pins are 3, 5, 6, 9, 10, 11 - will be in the array
 
 
  created 2oo9
  by Pavel Novak
  http://pavel-novak.net
*/

int nextTime = 100; //Time delay between start next LED
int pause = 100; //pause
int ledPins[] = {19,18,17,16}; //array with PWM pins
int ledPinsLength = 4; //ledPins[] lenght
int x; //key of ledPins array

//setup() method
void setup() {

  //initialize each pins as an output
  for(int x = 0;x < ledPinsLength; x++) {
    pinMode(ledPins[x], OUTPUT);
  }
}

//loop() method
void loop() {
  leftToRight(); //call left to right method
  rightToLeft(); //call right to left method
}

//from left to right lighting method
void leftToRight() {

  analogWrite(ledPins[0], 255); //turn on first LED
  delay(pause); //pause
  for(x = 1; x < ledPinsLength;x++) {
    analogWrite(ledPins[x], 255); //primary LED
    analogWrite(ledPins[x-1], 50); //secondary LED
    delay(nextTime); //pause between next LED
    turnOffLEDs(); //turn off all LEDs
  }
}

//from right to left lighting method
void rightToLeft() {

  analogWrite(ledPins[3], 255); //turn on first LED
  delay(pause); //pause
  for(x = ledPinsLength-2;x >= 0;x--) {
    analogWrite(ledPins[x], 255); //primary LED
    analogWrite(ledPins[x+1], 50); //secondary LED
    delay(nextTime); //pause between next LED
    turnOffLEDs(); //turn off all LEDs
  }
}

//turn off all LEDs
void turnOffLEDs() {
 
  for(int y = 0; y < ledPinsLength;y++) {
    analogWrite(ledPins[y], 0);
  }
}

Simon says game

/*Simon Says game by Robert Spann*/

int switch1 = 12; //The four button input pins
int switch2 = 11;
int switch3 = 10;
int switch4 = 9;
int led1 = 4; //LED pins
int led2 = 3;
int led3 = 2;
int led4 = 7;
int turn = 0;
int input1 = LOW;
int input2 = LOW;
int input3 = LOW;
int input4 = LOW;

int randomArray[100]; //Intentionally long to store up to 100 inputs (doubtful anyone will get this far)
int inputArray[100];


void setup() {

 Serial.begin(9600);

 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(led4, OUTPUT);
 pinMode(switch1, INPUT);
 pinMode(switch2, INPUT);
 pinMode(switch3, INPUT);
 pinMode(switch4, INPUT);
 randomSeed(analogRead(0)); //Added to generate "more randomness" with the randomArray for the output function

for (int y=0; y<=99; y++){ //For statement to loop through the output and input functions
  output();
  input();
}

  }
 
void output() { //function for generating the array to be matched by the player
   
  for (int y=turn; y <= turn; y++){ //Limited by the turn variable
   Serial.println(""); //Some serial output to follow along
   Serial.print("Turn: ");
   Serial.print(y);
   Serial.println("");
   randomArray[y] = random(1, 5); //Assigning a random number (1-4) to the randomArray[y], y being the turn count
   for (int x=0; x <= turn; x++){

     Serial.print(randomArray[x]);

     if (randomArray[x] == 1) {  //if statements to display the stored values in the array
       digitalWrite(led1, HIGH);
         tone(8, 400, 300);
         
       delay(300);
       digitalWrite(led1, LOW);
       delay(100);
     }

     if (randomArray[x] == 2) {
       digitalWrite(led2, HIGH);
         tone(8, 500, 300);
       delay(300);
       digitalWrite(led2, LOW);
       delay(100);
     }

     if (randomArray[x] == 3) {
       digitalWrite(led3, HIGH);
         tone(8, 600, 300);
       delay(300);
       digitalWrite(led3, LOW);
       delay(100);
     }

     if (randomArray[x] == 4) {
       digitalWrite(led4, HIGH);
         tone(8, 700, 300);
       delay(300);
       digitalWrite(led4, LOW);
       delay(100);
     }
    }
   }
  }
 
 
 
void input() { //Function for allowing user input and checking input against the generated array

 for (int x=0; x <= turn;){ //Statement controlled by turn count
   input1 = digitalRead(switch1);
   input2 = digitalRead(switch2);
   input3 = digitalRead(switch3);
   input4 = digitalRead(switch4);

   if (input1 == HIGH){ //Checking for button push
     digitalWrite(led1, HIGH);
       tone(8, 400, 300);
     delay(300);
     digitalWrite(led1, LOW);
     inputArray[x] = 1;
     delay(50);
     Serial.print(" ");
     Serial.print(1);
     if (inputArray[x] != randomArray[x]) { //Checks value input by user and checks it against
       fail();                              //the value in the same spot on the generated array
     }                                      //The fail function is called if it does not match
     x++;
   }

   if (input2 == HIGH){
     digitalWrite(led2, HIGH);
       tone(8, 500, 300);
     delay(300);
     digitalWrite(led2, LOW);
     inputArray[x] = 2;
     delay(50);
     Serial.print(" ");
     Serial.print(2);
     if (inputArray[x] != randomArray[x]) {
       fail();
     }
     x++;

   }

   if (input3 == HIGH){
     digitalWrite(led3, HIGH);
       tone(8, 600, 300);
     delay(300);
     digitalWrite(led3, LOW);
     inputArray[x] = 3;
     delay(50);
     Serial.print(" ");
     Serial.print(3);
     if (inputArray[x] != randomArray[x]) {
       fail();
     }
     x++;

   }

   if (input4 == HIGH){

     digitalWrite(led4, HIGH);
       tone(8, 700, 300);
     delay(300);
     digitalWrite(led4, LOW);
     inputArray[x] = 4;
     delay(50);
     Serial.print(" ");
     Serial.print(4);
     if (inputArray[x] != randomArray[x]) {
       fail();
     }
     x++;

   }
  }
 delay(500);
 turn++; //Increments the turn count, also the last action before starting the output function over again
}

void fail() { //Function used if the player fails to match the sequence
 
 for (int y=0; y<=5; y++){ //Flashes lights for failure
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  digitalWrite(led3, HIGH);
  digitalWrite(led4, HIGH);
    tone(8, 900, 400);
  delay(400);
  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);
  digitalWrite(led3, LOW);
  digitalWrite(led4, LOW);
  delay(200);
 }
 delay(500);
 turn = -1; //Resets turn value so the game starts over without need for a reset button
}

void loop() { //Unused void loop(), though for some reason it doesn't compile without this /shrug
}

The codes are not from me but a little bit changed an working.

Sorry for my bad engl I am from Germany. :slight_smile:

Thanks

The IR remote control with Servo code did not fit in the first post :slight_smile:

// 0.1 by pmalmsten
// 0.2 by farkinga
#include <Servo.h> 
Servo myservo;
#define IR_BIT_LENGTH 12
#define BIT_1 1000          //Binary 1 threshold (Microseconds)
#define BIT_0 400           //Binary 0 threshold (Microseconds)
#define BIT_START 2000      //Start bit threshold (Microseconds)
#define DEBUG 0             //Serial connection must be started to debug
#define IR_PIN 13            //Sensor pin 1 wired through a 220 ohm resistor
//#define LED_PIN 9           //"Ready to Recieve" flag, not needed but nice
//#define POWER2_PIN 10
//#define POWER_PIN 11     // the red LED that indicates if the power button is pressed.

int runtime_debug = 0;
int output_key = 0;
int power_button = 0;
int power2_button = 0;

void setup() {
 // pinMode(LED_PIN, OUTPUT);		//This shows when we're ready to recieve
  //pinMode(POWER_PIN, OUTPUT);
  //pinMode(POWER2_PIN, OUTPUT);		//This is the "power on" indicator
  pinMode(IR_PIN, INPUT);
  myservo.attach(6);  // attaches the servo on pin 9 to the servo object 
  //digitalWrite(LED_PIN, LOW);	    //not ready yet
  Serial.begin(9600);
}

void loop() {
  //digitalWrite(LED_PIN, HIGH);	   //Ok, i'm ready to recieve

  int key = get_ir_key();		    //Fetch the key

  //digitalWrite(LED_PIN, LOW);

  do_response(key);

  delay(200);
}

void do_response(int key)
{
  switch (key)
  {
    case 1437:
      Serial.println("toggle debug pulse");
      runtime_debug = 1 - runtime_debug;
      break;
    case 1498:
      Serial.println("Toggle key output");
      output_key = 1 - output_key;
      break;
    case 149:
      Serial.println("Power");
      power_button = 1 - power_button;
      if (power_button)
      {
      myservo.write(160);       // auf           // sets the servo position according to the scaled value 
      delay(2000);
      myservo.write(20);    // zurück
      delay(200);  // waits for the servo to get there 
        //digitalWrite(POWER_PIN, HIGH);
      }
      else
      {
        //digitalWrite(POWER_PIN, LOW);
      }
      break;
    case 1424:
      Serial.println("Channel Up");
       power2_button = 1 - power2_button;
        if (power2_button)
      {
        //digitalWrite(POWER2_PIN, HIGH);
      }
      else
      {
        //digitalWrite(POWER2_PIN, LOW);
      }
      break;
    case 1425:
      Serial.println("Channel Down");
      break;
       case 146:
      Serial.println("+");
      break;
       case 147:
      Serial.println("-");
      break;
       case 1408:
      Serial.println("1");
      break;
       case 1409:
      Serial.println("2");
      break;
       case 1410:
      Serial.println("3");
      break;
       case 1411:
      Serial.println("4");
      break;
       case 1412:
      Serial.println("5");
      break;
       case 1413:
      Serial.println("6");
      break;
       case 1414:
      Serial.println("7");
      break;
       case 1415:
      Serial.println("8");
      break;
       case 1416:
      Serial.println("9");
      break;
       case 1417:
      Serial.println("0");
      break;
    default:
      if (output_key)
      {
        Serial.print("Key ");
        Serial.print(key);
        Serial.println(" not programmed");
      }
      break;
  }
}

void read_pulse(int data[], int num_bits)
{
  for (int i = 0; i < num_bits; i++)
  {
    data[i] = pulseIn(IR_PIN, LOW);
  }
}

void pulse_to_bits(int pulse[], int bits[], int num_bits)
{
  if (DEBUG || runtime_debug) { Serial.println("-----"); }

  for(int i = 0; i < num_bits ; i++)
  {
    if (DEBUG || runtime_debug) { Serial.println(pulse[i]); }

    if(pulse[i] > BIT_1) //is it a 1?
    {
      bits[i] = 1;
    }
    else if(pulse[i] > BIT_0) //is it a 0?
    {
      bits[i] = 0;
    } 

    else //data is invalid...
    {
      Serial.println("Error");
    }
  }
}

int bits_to_int(int bits[], int num_bits)
{
  int result = 0;
  int seed = 1;

  //Convert bits to integer
  for(int i = 0 ; i < num_bits ; i++)
  {
    if(bits[i] == 1)
    {
	result += seed;
    }

    seed *= 2;
  }

  return result;
}

int get_ir_key()
{
  int pulse[IR_BIT_LENGTH];
  int bits[IR_BIT_LENGTH];  

  do {} //Wait for a start bit
  while(pulseIn(IR_PIN, LOW) < BIT_START);

  read_pulse(pulse, IR_BIT_LENGTH);

  pulse_to_bits(pulse, bits, IR_BIT_LENGTH);

  return bits_to_int(bits, IR_BIT_LENGTH);
}

In the Readme.txt file:

c. In the main Program Chooser sketch, go to the voids labeled prgrm1, prgrm2

Got to love it when someone develops a complex application without a clue about proper terminology, even.

Other than that, the instructions seem pretty straightforward. What part are you having problems with?

Yes the instructions are good but i think i have problems to translate it right.

I am a hardware boy everything is already built

first problem i don't want that the buttons choose the program. it should go on the IR remote control

second problem i have tried to make combine 4 blink skechtes with 4 different frequencies. unhappily he does not compile.

i dont know how easy this is but best is an example sketch with these 4 blinking frequencies at first :)

first problem
i don’t want that the buttons choose the program. it should go on the IR remote control

That is going to require a rather major re-work of the Sketch Chooser sketch. Not all that difficult, but not trivial, either.

second problem
i have tried to make combine 4 blink skechtes with 4 different frequencies.
unhappily he does not compile.

Then, you have two choices. You can either give him a stern lecture about proper behavior, in the hope that this might do some good, or you can post the code you came up with, along with the compiler output.

Ok i think i have got it. he is compiling the blinks :) it was easy sorry for my post

at home i will test it.

Know i must solve the thing with the IR remote.

this ist my code

/************************************************************************/
/*                                                                 
    Copyright (c) 2011 by Richard Eberheim                                
                            

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 ************************************************************************/

/*  History
 * When        Who                 Comments
 * 06/14/11    Richard Eberheim    Initial authoring.

 */


// These voids below are for configuring which programs should take which slots.
void prgrm1()
{// place here the name of the void in the file you wish to be program 1
blinkloop();
}


void prgrm2()
{// place here the name of the void in the file you wish to be program 2
blink2loop();
}


void prgrm3()
{// place here the name of the void in the file you wish to be program 3
blink3loop();
}


void prgrm4()
{// place here the name of the void in the file you wish to be program 4
blink4loop();
}
  
  
void setups()
{ // place here the names of the voids you wish to be the setups for all of the other programs
 void blinksetup();
 void blink2setup();
 void blink3setup();
 void blink4setup();
 }

unsigned long endtimer = 0;
unsigned long starttimer = 0;
boolean run = false;
int programnum = 0;
const int buttonPrgmSet = 2;
const int buttonRun = 3;
const int ledPin1 =  10;
const int ledPin2 =  11;      
const int ledPin3 =  12;
const int ledPin4 =  13;

int runfaderbrightness = 255;
int runfaderbrightnesschange;
void setup() {




  pinMode(buttonPrgmSet, INPUT);
  pinMode(buttonRun, INPUT); 
 Serial.begin(9600); 
 setups();
}

void loop(){

  if ((digitalRead(buttonPrgmSet)) == LOW)
   {     
    // turn LED on:
    run = false;    
   programnum = programnum + 1;

    if (programnum == 4)   
    {
      programnum = 0;
    }
    while ((digitalRead(buttonPrgmSet)) == LOW)
    {
      Serial.println("button1");
    }
    
  }
  if ((digitalRead(buttonRun)) == LOW)
  {
    if (run == true)
    {
      run = false; 
    }
    else
    {
      run = true; 
    }
    while ((digitalRead(buttonRun)) == LOW)
    {
      
     Serial.println("button2");
  }
    
  }
if (run == true)
{
  unsigned long time = millis();
 if (time - starttimer  > 750)
 {
  
   starttimer = millis();
   if (runfaderbrightness == 255)
   {
      Serial.println("got through set low");
    runfaderbrightness = 0; 
   }
   else
   {
      Serial.println("got through set high");
      runfaderbrightness = 255; 
   }
 }
}
else
{
  runfaderbrightness = 0;
}
  switch (programnum)
  {
  case 0:

    if (run == true)
    {
      analogWrite(ledPin1, runfaderbrightness);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
      prgrm1();
    }
    else
    {
      analogWrite(ledPin1, 255);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
    }

    break;

  case 1:
    if (run == true)
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, runfaderbrightness);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
      prgrm2();
    }
    else
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 255);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
    }
    break;
  case 2:
    if (run == true)
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, runfaderbrightness);
      analogWrite(ledPin4, 0);
      prgrm3();
    }
    else
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 255);
      analogWrite(ledPin4, 0);
    }
    break;
  case 3:
    if (run == true)
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, runfaderbrightness);
      prgrm4();
    }
    else
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 255);
      ; 
    }
    break;
  }
}
void setups()
{ // place here the names of the voids you wish to be the setups for all of the other programs
 void blinksetup();
 void blink2setup();
 void blink3setup();
 void blink4setup();
 }

You seem to have the same issue with terminology as the author of the original code. The name of your setup function is NOT "void blinksetup". It IS blinksetup. Get rid of the word void in front of the function name, so it becomes a function call, instead of a misplaced function prototype.

OK thanks

any idee to modify

the IR code

// 0.1 by pmalmsten
// 0.2 by farkinga
#include <Servo.h> 
Servo myservo;
#define IR_BIT_LENGTH 12
#define BIT_1 1000          //Binary 1 threshold (Microseconds)
#define BIT_0 400           //Binary 0 threshold (Microseconds)
#define BIT_START 2000      //Start bit threshold (Microseconds)
#define DEBUG 0             //Serial connection must be started to debug
#define IR_PIN 13            //Sensor pin 1 wired through a 220 ohm resistor
//#define LED_PIN 9           //"Ready to Recieve" flag, not needed but nice
//#define POWER2_PIN 10
//#define POWER_PIN 11     // the red LED that indicates if the power button is pressed.

int runtime_debug = 0;
int output_key = 0;
int power_button = 0;
int power2_button = 0;

void setup() {
 // pinMode(LED_PIN, OUTPUT);		//This shows when we're ready to recieve
  //pinMode(POWER_PIN, OUTPUT);
  //pinMode(POWER2_PIN, OUTPUT);		//This is the "power on" indicator
  pinMode(IR_PIN, INPUT);
  myservo.attach(6);  // attaches the servo on pin 9 to the servo object 
  //digitalWrite(LED_PIN, LOW);	    //not ready yet
  Serial.begin(9600);
}

void loop() {
  //digitalWrite(LED_PIN, HIGH);	   //Ok, i'm ready to recieve

  int key = get_ir_key();		    //Fetch the key

  //digitalWrite(LED_PIN, LOW);

  do_response(key);

  delay(200);
}

void do_response(int key)
{
  switch (key)
  {
    case 1437:
      Serial.println("toggle debug pulse");
      runtime_debug = 1 - runtime_debug;
      break;
    case 1498:
      Serial.println("Toggle key output");
      output_key = 1 - output_key;
      break;
    case 149:
      Serial.println("Power");
      power_button = 1 - power_button;
      if (power_button)
      {
      myservo.write(160);       // auf           // sets the servo position according to the scaled value 
      delay(2000);
      myservo.write(20);    // zurück
      delay(200);  // waits for the servo to get there 
        //digitalWrite(POWER_PIN, HIGH);
      }
      else
      {
        //digitalWrite(POWER_PIN, LOW);
      }
      break;
    case 1424:
      Serial.println("Channel Up");
       power2_button = 1 - power2_button;
        if (power2_button)
      {
        //digitalWrite(POWER2_PIN, HIGH);
      }
      else
      {
        //digitalWrite(POWER2_PIN, LOW);
      }
      break;
    default:
      if (output_key)
      {
        Serial.print("Key ");
        Serial.print(key);
        Serial.println(" not programmed");
      }
      break;
  }
}

void read_pulse(int data[], int num_bits)
{
  for (int i = 0; i < num_bits; i++)
  {
    data[i] = pulseIn(IR_PIN, LOW);
  }
}

void pulse_to_bits(int pulse[], int bits[], int num_bits)
{
  if (DEBUG || runtime_debug) { Serial.println("-----"); }

  for(int i = 0; i < num_bits ; i++)
  {
    if (DEBUG || runtime_debug) { Serial.println(pulse[i]); }

    if(pulse[i] > BIT_1) //is it a 1?
    {
      bits[i] = 1;
    }
    else if(pulse[i] > BIT_0) //is it a 0?
    {
      bits[i] = 0;
    } 

    else //data is invalid...
    {
      Serial.println("Error");
    }
  }
}

int bits_to_int(int bits[], int num_bits)
{
  int result = 0;
  int seed = 1;

  //Convert bits to integer
  for(int i = 0 ; i < num_bits ; i++)
  {
    if(bits[i] == 1)
    {
	result += seed;
    }

    seed *= 2;
  }

  return result;
}

int get_ir_key()
{
  int pulse[IR_BIT_LENGTH];
  int bits[IR_BIT_LENGTH];  

  do {} //Wait for a start bit
  while(pulseIn(IR_PIN, LOW) < BIT_START);

  read_pulse(pulse, IR_BIT_LENGTH);

  pulse_to_bits(pulse, bits, IR_BIT_LENGTH);

  return bits_to_int(bits, IR_BIT_LENGTH);
}

And the chooser code

/************************************************************************/
/*                                                                 
 	Copyright (c) 2011 by Richard Eberheim                                
 	                        
 
 	This library is free software; you can redistribute it and/or
 	modify it under the terms of the GNU Lesser General Public
 	License as published by the Free Software Foundation; either
 	version 2.1 of the License, or (at your option) any later version.
 
 	This library is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 	Lesser General Public License for more details.
 
 	You should have received a copy of the GNU Lesser General Public
 	License along with this library; if not, write to the Free Software
 	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 ************************************************************************/

/*  History
 * When        Who                 Comments
 * 06/14/11    Richard Eberheim    Initial authoring.

 */


// These voids below are for configuring which programs should take which slots.
void prgrm1()
{// place here the name of the void in the file you wish to be program 1
blinkloop();
}


void prgrm2()
{// place here the name of the void in the file you wish to be program 2
blink2loop();
}


void prgrm3()
{// place here the name of the void in the file you wish to be program 3
blink3loop();
}


void prgrm4()
{// place here the name of the void in the file you wish to be program 4
blink4loop();
}
  
  
void setups()
{ // place here the names of the voids you wish to be the setups for all of the other programs
blinksetup();
blink2setup();
blink3setup();
blink4setup();
 }

unsigned long endtimer = 0;
unsigned long starttimer = 0;
boolean run = false;
int programnum = 0;
const int buttonPrgmSet = 2;
const int buttonRun = 3;
const int ledPin1 =  10;
const int ledPin2 =  11;      
const int ledPin3 =  12;
const int ledPin4 =  13;

int runfaderbrightness = 255;
int runfaderbrightnesschange;
void setup() {




  pinMode(buttonPrgmSet, INPUT);
  pinMode(buttonRun, INPUT); 
 Serial.begin(9600); 
 setups();
}

void loop(){

  if ((digitalRead(buttonPrgmSet)) == LOW)
   {     
    // turn LED on:
    run = false;    
   programnum = programnum + 1;

    if (programnum == 4)   
    {
      programnum = 0;
    }
    while ((digitalRead(buttonPrgmSet)) == LOW)
    {
      Serial.println("button1");
    }
    
  }
  if ((digitalRead(buttonRun)) == LOW)
  {
    if (run == true)
    {
      run = false; 
    }
    else
    {
      run = true; 
    }
    while ((digitalRead(buttonRun)) == LOW)
    {
      
     Serial.println("button2");
  }
    
  }
if (run == true)
{
  unsigned long time = millis();
 if (time - starttimer  > 750)
 {
  
   starttimer = millis();
   if (runfaderbrightness == 255)
   {
      Serial.println("got through set low");
    runfaderbrightness = 0; 
   }
   else
   {
      Serial.println("got through set high");
      runfaderbrightness = 255; 
   }
 }
}
else
{
  runfaderbrightness = 0;
}
  switch (programnum)
  {
  case 0:

    if (run == true)
    {
      analogWrite(ledPin1, runfaderbrightness);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
      prgrm1();
    }
    else
    {
      analogWrite(ledPin1, 255);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
    }

    break;

  case 1:
    if (run == true)
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, runfaderbrightness);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
      prgrm2();
    }
    else
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 255);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 0);
    }
    break;
  case 2:
    if (run == true)
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, runfaderbrightness);
      analogWrite(ledPin4, 0);
      prgrm3();
    }
    else
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 255);
      analogWrite(ledPin4, 0);
    }
    break;
  case 3:
    if (run == true)
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, runfaderbrightness);
      prgrm4();
    }
    else
    {
      analogWrite(ledPin1, 0);
      analogWrite(ledPin2, 0);
      analogWrite(ledPin3, 0);
      analogWrite(ledPin4, 255);
      ; 
    }
    break;
  }
}

What does the of the Simon says Game code cause

void setup() {

for (int y=0; y<=99; y++){ //For statement to loop through the output and input functions
output();
input();

}

I think the setup code run once and why the output and input functions run in a loop?