Tuesday, December 3, 2013

The Code

Here is the code that I tried for the circuit:

First is the one I used for the performance:

//EL wire
int white = 9;
int orange = 11;
int green = 13;


long randNumber;

// the setup routine runs once when you press reset:
void setup()
{
  // initialize
  pinMode(white, OUTPUT);
  pinMode (orange, OUTPUT);
  pinMode (green, OUTPUT);

}

// the loop routine runs over and over again forever:
void loop()
{
  digitalWrite(white, HIGH);


  digitalWrite(green, HIGH);
  delay(600);
  digitalWrite(green, LOW);
  delay(600);

  randNumber = random (50, 250);
  digitalWrite(orange, HIGH);
  delay(randNumber);
  digitalWrite(orange, LOW);
  delay(randNumber);

  }

This is a code that I attempted with the copper pieces:

//EL wire
int white = 9;
int orange = 11;
int green = 13;

// SWITCHES
int whiteConnect = 2;
int orangeConnect = 3;
int greenConnect = 5;

long randNumber;

// the setup routine runs once when you press reset:
void setup()
{
  // initialize
  pinMode(white, OUTPUT);
  pinMode (orange, OUTPUT);
  pinMode (green, OUTPUT);

  pinMode (whiteConnect, INPUT);
  pinMode (orangeConnect, INPUT);
  pinMode (greenConnect, INPUT);

  Serial.begin(9600);

  digitalWrite(whiteConnect,LOW);
    digitalWrite(orangeConnect,LOW);
  digitalWrite(greenConnect,LOW);
}

// the loop routine runs over and over again forever:
void loop()
{
  if (whiteConnect == LOW)
  {
    digitalWrite(white, HIGH);
  }
  else {
    digitalWrite(white,LOW);

  }


  if (greenConnect == LOW)
  {
  digitalWrite(green, HIGH);
  delay(600);
  digitalWrite(green, LOW);
  delay(600);
  }
  else {
  digitalWrite(green,LOW);
  }

  if (orangeConnect == LOW)

  {
  randNumber = random (50, 250);
  digitalWrite(orange, HIGH);
  delay(randNumber);
  digitalWrite(orange, LOW);
  delay(randNumber);
  }
  else {
    digitalWrite(orange,LOW);
  }
}

This is another code I attempted with the copper pieces:

// give it a name:
int white = 9;
int orange = 11;
int green = 13;
int whiteConnect = 1;
int orangeConnect = 3;
int greenConnect = 5;
int maskConnect = 7;

long randNumber;

// the setup routine runs once when you press reset:
void setup()
{
  // initialize
  pinMode(white, OUTPUT);
  pinMode (orange, OUTPUT);
  pinMode (green, OUTPUT);

  pinMode (whiteConnect, INPUT);
  pinMode (orangeConnect, INPUT);
  pinMode (greenConnect, INPUT);

  pinMode (maskConnect, INPUT);

  // These constants won't change:
const int maskConnect = 7;    // pin that the Main Mask is attached to
const int whiteConnect = 1;       // pin that the White Mask attached to
const int orangeConnect = 3;       // pin that the Orange Mask attached to
const int greenConnect = 5;       // pin that the Green Mask attached to
}

// the loop routine runs over and over again forever:
void loop()
{
  if (maskConnect == whiteConnect)
  {
    digitalWrite(white, HIGH);
  }
  else {
    digitalWrite(white,LOW);
  }

  if (maskConnect == greenConnect)
  {
  digitalWrite(green, HIGH);
  delay(600);
  digitalWrite(green, LOW);
  delay(600);
  }
  else {
  digitalWrite(green,LOW);
  }

  if (maskConnect == orangeConnect)
  {
  randNumber = random (50, 250);
  digitalWrite(orange, HIGH);
  delay(randNumber);
  digitalWrite(orange, LOW);
  delay(randNumber);
  }
  else {
    digitalWrite(orange,LOW);
  }
}

Here is a code I tried when troubleshooting:

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor

 This example code is in the public domain.
 */

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 3;

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  // make the pushbutton's pin an input:
  pinMode(pushButton, INPUT);
  digitalWrite(pushButton, HIGH);
}
// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int buttonState = digitalRead(pushButton);
  // print out the state of the button:
  Serial.println(buttonState);
  delay(10);        // delay in between reads for stability
}

No comments:

Post a Comment