Wednesday 12/9/09

posted Dec 9, 2009, 9:28 AM by Unknown user   [ updated Dec 9, 2009, 9:11 AM by Unknown user ]
YESTERDAY
We attempted to light two segments of multiple LED combinations with a single microsecond of delay to give the appearance of both being lit up at the same time. Due to pins set as outputs in between the LEDs we were trying to light, other LEDs lit up even though the code was not designed to power those LEDs. An example of this would be setting 11 to high and 8 to low and then 13 to high and 7 to low. Besides lighting up these two LEDs, you would also light up LED 13,8. (code for this would be:
int an[] = {11,12,13,11,12,13,10,13,10,12,10,11,10,9,9,11,12,9,8,11,8,10,8,9,8,7,9,7,10,7,7,11,12,7,13,7};
int ca[] = {12,11,11,13,13,12,13,10,12,10,11,10,9,10,11,9,9,12,11,8,10,8,9,8,7,8,7,9,7,10,11,7,7,12,7,13};

int a = 13;
int b = 12;
int c = 11;
int d = 10;
int e = 9;
int f = 8;
int g = 7;
int y = 0;
int t = 1;

void setup(){
for (int pin =7; pin<=13; pin++)
{
  pinMode(pin,INPUT);        //sets pins 7-13 as inputs
}
}

void loop() {
pinMode(an[34], OUTPUT);     //sets pin 13 as an output
pinMode(an[31], OUTPUT);     //sets pin 11 as an output
pinMode(ca[34], OUTPUT);     //sets pin 7 as an output
pinMode(ca[25], OUTPUT);     // sets pin 8 as an output
digitalWrite(an[34], HIGH);       //sets pin 13 to high
digitalWrite(an[31], HIGH);       //sets pin 11 to high
digitalWrite(ca[34], LOW);        //sets pin 7 to low
digitalWrite(ca[25], LOW);        //sets pin 7 to low
}

TODAY
In an attempt to fix this problem (which I am assuming is caused by Joe's segment of code), I will be adding on to my code with similar code to light up more LEDs. My code uses one pin set at low to act as the ground for multiple pins set to high which should prevent light up extra pins. Another way to avoid it might be to use one high pin to multiple low pins (exactly what I told Joe to try). So by using a combination of these segments of code, it should be possible to light up letters without them blinking due to the numerous delays. Based on the how the code below continued to light up other LEDs, I changed the timing from microseconds to seconds. When I changed the timing, the other LEDs turned off, so I concluded that as the timing reduced the code must be infringing on the lighting sequences.

int an[] = {11,12,13,11,12,13,10,13,10,12,10,11,10,9,9,11,12,9,8,11,8,10,8,9,8,7,9,7,10,7,7,11,12,7,13,7};
int ca[] = {12,11,11,13,13,12,13,10,12,10,11,10,9,10,11,9,9,12,11,8,10,8,9,8,7,8,7,9,7,10,11,7,7,12,7,13};
int array [6][6]=
{
  {0,1,2,3,4,5},
  {6,7,8,9,10,11},
  {12,13,14,15,16,17},
  {18,19,20,21,22,23},
  {24,25,26,27,28,29},
  {30,31,32,33,34,35},
};
int a = 13;
int b = 12;
int c = 11;
int d = 10;
int e = 9;
int f = 8;
int g = 7;
int y = 0;
int t = 1000;
int i = 1000;
int u = 400;

void setup(){
for (int pin =7; pin<=13; pin++)
{
  pinMode(pin,INPUT);
}
}

void loop()
  {
    pinMode (ca[34], OUTPUT);
    pinMode (an[34], OUTPUT);
    pinMode (an[32], OUTPUT);
    pinMode (an[31], OUTPUT);
    pinMode (an[26], OUTPUT);
    pinMode (an[24], OUTPUT);
    digitalWrite (ca[34], LOW);
    digitalWrite (an[34], HIGH);
    digitalWrite (an[32], HIGH);
    digitalWrite (an[31], HIGH);
    digitalWrite (an[26], HIGH);
    digitalWrite (an[24], HIGH);
    delayMicroseconds(t);
    pinMode (an[31], INPUT);
    pinMode (an[26], INPUT);
    pinMode (an[24], INPUT);
    digitalWrite (ca[34], HIGH);
    digitalWrite (an[34], LOW);
    digitalWrite (an[32], LOW);
    delayMicroseconds(t);
    pinMode (an[34], INPUT);
    pinMode (an[32], INPUT);
    pinMode (ca[34], INPUT);
    delayMicroseconds(t);
  }














Comments