Ira – Prototyping

I spent a LOT of time trying to solve the code and the hardware issues.
Eventually, for the latest prototype I used the code and the hardware connections that I made before (with a few improvements).

Sketches

Some of the code exp. that I was working on:

***************************************************
***************************************************
// Made with Pablo Ripollés
***************************************************

/* sheep
 */

int inPin = 7;         // the number of the input pin
int outPin = 13;       // the number of the output pin

int state = HIGH;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

// the follow variables are long’s because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 200;   // the debounce time, increase if the output flickers

void setup()
{
  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
}

void loop()
{
  b1Reading = digitalRead(b1Pin);
  b2Reading = digitalRead(b2Pin);
  b3Reading = digitalRead(b3Pin);

  // if we just pressed the button (i.e. the input went from LOW to HIGH),
  // and we’ve waited long enough since the last press to ignore any noise… 
  if (b1Reading == HIGH && lastb1Reading == LOW && millis() – time > debounce)
  {
    alpha = HIGH;
    // … and remember when the last button press was
    time = millis();   
  }

  if (b2Reading == HIGH && lastb2Reading == LOW && millis() – time > debounce)
  {
    alpha = LOW;
    beta = HIGH;
    // … and remember when the last button press was
    time = millis();   
  }

  if (b3Reading == HIGH && lastb3Reading == LOW && millis() – time > debounce)
  {
    alpha = LOW;
    beta = LOW;
    // … and remember when the last button press was
    time = millis();   
  }

  if (alpha == HIGH)
  {
    ddddddd
  }
  else if (alpha == LOW)
  {
    if (beta = HIGH)
    {
    }
    else if (beta = LOW)
    {
    }
  }

  lastb1Reading = b1Reading;
  lastb2Reading = b2Reading;
  lastb3Reading = b3Reading;
}

***************************************************
***************************************************
// Made with Pablo Ripollés
***************************************************
int pins[] = {3, 5, 6, 9, 10};
int numPins = 5;

float Deltat;
float minDeltat = 3000.0;
float maxDeltat = 7000.0;

int value;
int minValue = 0;
int maxValue = 255;

void setup()
{
  //
}

void loop()
{

for (int j=0; j<=9; j++)
{

  Deltat = minDeltat + 9*j/(maxDeltat – minDeltat);

  for (int i=numPins-1; i>=0; i–) // from last group to first group
  {
    for (int t=0; t<=Deltat/2; t+=5) // fade-in
    {
      value = minValue + 2*t*(maxValue – minValue)/Deltat;
      analogWrite(pins[i], value);
      delay(10);
    }
    for (int t=Deltat/2; t<=Deltat; t+=5) // fade-out
    {
      value = minValue – 2*(t – Deltat)*(maxValue – minValue)/Deltat;
      analogWrite(pins[i], value);
      delay(10);
    }
  }

  for (int i=1; i<=numPins-2; i++)
  {
    for (int t=0; t<=Deltat/2; t+=5) // fade-in
    {
      value = minValue + 2*t*(maxValue – minValue)/Deltat;
      analogWrite(pins[i], value);
      delay(10);
    }
    for (int t=Deltat/2; t<=Deltat; t+=5) // fade-out
    {
      value = minValue – 2*(t – Deltat)*(maxValue – minValue)/Deltat;
      analogWrite(pins[i], value);
      delay(10);
    }
  }
}

//

}

***************************************************
***************************************************

This is the final code, for today:

reference from: http://www.slideshare.net/bruzed/student-lecture-3?type=presentation

***************************************************

int value = 12;
int pins[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
int numPins = 13;

void setup()
{
  //
}

void loop()
{

  int i;

  for (i=13 ; i>=0; i–)
    {
      for(value=0; value<=255; value+=5)
        {
          analogWrite(pins[i], value);
          delay(30);
        }
    }

    int j;
    for (j=0; j<=numPins; j++)
      {
        for(value=255; value>=0; value-=5)
        {
          analogWrite(pins[j], value);
          delay(30);
        }
      }

}

One of the hardware prototypes:

DSC02199

Tried different colors:

DSC02201

http://vimeo.com/moogaloop.swf?clip_id=3562095&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1
LampPrototype from Ira Goldberg on Vimeo.