Show Posts
Pages: [1]
1  Using Arduino / Installation & Troubleshooting / Re: Installing bootloader on Mege2560 on: July 10, 2014, 11:24:00 am
Thanks a bunch, Gammon Atmega Bootloader Programmer worked like a charm. Used Uno to program Mega2560.

Theron
2  Using Arduino / Installation & Troubleshooting / Installing bootloader on Mege2560 on: July 09, 2014, 09:14:20 am
I believe I've zapped my bootloader (power disconnect during upload?). How can I install a new bootloader? I've been reading a bit and looks like I need to buy a programmer like USBtinyISP. I also note using an UNO to install a bootloader on another UNO. Can I do this with the Mega 2560. Mine is a China knockoff.

Thanks,
Theron Wierenga
Norton Shores, MI
3  Using Arduino / LEDs and Multiplexing / Re: Need help with multiple instances of LedControl for 32x32 LED array on: February 08, 2014, 08:48:23 am
OK, I reduced instances to just two

Code:
LedControl lc1=LedControl(12,11,10,numarrays);
LedControl lc2=LedControl(4,3,9,numarrays);

where numarrays = 4 and lc1 is wired to the first row and lc2 is wired to the second row. If I place an 8x8 LED array in the first row, with nothing in the second row, it works. If I place and 8x8 LED array in the second row, with nothing in the first row, it works. If I place an 8x8 LED array in both first and second rows only the first row works.

This library appears to have been written predominately for use with 7 segment displays. My next step is writing my own library.

Thanks, Theron
4  Using Arduino / LEDs and Multiplexing / Re: Need help with multiple instances of LedControl for 32x32 LED array on: February 07, 2014, 08:19:21 pm
OK, I think I have the code marked correctly. Sorry I missed that.

My idea was to use a 4x4 array of 8x8 LED displays. I purchased the 8x8 displays from China, they come with a little board, the MAX 7219 IC and the display - very inexpensive and decent quality. My only complaint was that the pin spacing on the board was 1.16 inches instead of 1.1, making layout of a motherboard for all 16 units a little difficult, but the results were OK.

I then wanted to create 4 instances of the LedControl, one for each row of four 8x8 displays. This helps a little with symmetry going from a 32x32 array for Conway's Game of Life to the individual 8x8 displays. The documentation at http://www.wayoda.org/arduino/ledcontrol/index.html shows this example.

Code:
/* we have to include the library */
#include "LedControl.h"

// Create a new LedControl for 8 devices...
LedControl lc1=LedControl(12,11,10,8);

// ... and another one, now we control 1024 Leds's from an arduino, not bad!
// The second one must use different pins!
LedControl lc2=LedControl(9,8,7,8);

And here's what I've done.

Code:
LedControl lc1=LedControl(12,11,10,numarrays);
LedControl lc2=LedControl(4,3,9,numarrays);
LedControl lc3=LedControl(32,30,8,numarrays);
LedControl lc4=LedControl(28,27,7,numarrays);

Unfortunately, it doesn't work.

I've enjoyed Conway's Game of Life also. This little device was something I wanted to make for my son's desk. I have also programed a 3D version in Microsoft WPF.

Thanks, Theron
5  Using Arduino / LEDs and Multiplexing / Re: Need help with multiple instances of LedControl for 32x32 LED array on: February 07, 2014, 12:50:45 pm
OK, here's the code. The Game of Life code appears to be working OK, and it is displayed correctly in the top row of 4 8x8 displays. I chose to go with four instances of LedControl so that the ripple through would only have to go through four displays across.

This is a work in progress, later I'll add RTC to the display as well.

-------------------------

Code:
// 8x8 Matrix Test

//We always have to include the libraries
#include "LedControl.h"
#include <dht.h>
#include <SPI.h>

/* we always wait a bit between updates of the display */
int delaytime = 2000;
int numarrays = 4;
int indexym1, indexy, indexyp1;
byte aray[1024];
byte newaray[1024];
byte lastaray[1024];
//byte thirdaray[1024];
byte sum = 0;
byte lastsecond = 0;
byte second, minute, hour, ampm, dayOfWeek, dayOfMonth, month, year, f1224, t1, t2, f100, f10, f1;
double lasttemp = 0, currenttemp = 0, humidity = 0;

LedControl lc1=LedControl(12,11,10,numarrays); // These have to be here because of scope
LedControl lc2=LedControl(36,34,9,numarrays);
LedControl lc3=LedControl(32,30,8,numarrays);
LedControl lc4=LedControl(28,27,7,numarrays);

dht DHT;                                       // The DHT22 Temperature Humidity sensor
#define DHT22_PIN 41


void setup()
{
  f1224 = 1;
  RTC_init_DS3234();
  //day(1-31), month(1-12), year(0-99), dayofweek (1-7), ampm (0-1), hour(0-23), minute(0-59), second(0-59), 12/24 hr (0-1)
  //                                    Sun = 1          0 = am, 1 = pm                                      0 = 24 hr.
  //SetTimeDate_DS3234(19,12,13,5,1,3,51,30,1);
  
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
   for (int i=0;i < numarrays; i++)
   {
      lc1.shutdown(i,false);
      lc2.shutdown(i,false);
      lc3.shutdown(i,false);
      lc4.shutdown(i,false);
      /* Set the brightness to a low values */
      lc1.setIntensity(i,1);
      lc2.setIntensity(i,1);
      lc3.setIntensity(i,1);
      lc4.setIntensity(i,1);
      /* and clear the display */
      lc1.clearDisplay(i);
      lc2.clearDisplay(i);
      lc3.clearDisplay(i);
      lc4.clearDisplay(i);
   }
  
  for (int i=0; i < 1024; i++)
  {
     aray[i] = 0;
     newaray[i] = 0;
     lastaray[i] = 0;
  }

  SeedArray();
  Display_8x8();
  delay(delaytime);
//  Serial.begin(9600);
 
}

void loop()
{
Game_of_Life();
//  lc1.clearDisplay(0);
//  lc1.clearDisplay(1);
//  lc1.clearDisplay(2);
//  lc1.clearDisplay(3);
//  delay(1000);
//  for (int j=0; j<18;j++)
//  {
//      for (int i=0;i<5;i++)
//      {
//        lc1.setColumn(0,i,alpha[i+j*5]);
//        lc1.setColumn(1,i,alpha[i+j*5]);
//        lc1.setColumn(2,i,alpha[i+j*5]);
//      }
//      delay(1000);
//  }

//  for (int i=4; i< 7; i++)
//  {
//      Show_Number(0,i-4,i);
//      // Show_DayofWeek(i);
//      
//     delay(1500);
//  }

//for (int i=0;i<8;i++)
//      {
//        lc2.setColumn(0,i,255);
//        lc2.setColumn(1,i,255);
//        lc2.setColumn(2,i,255);
//        lc2.setColumn(3,i,255);
//      }
//delay(1000);
}

void Game_of_Life()
{
   for (int y = 1; y <= 30; y++)
  {
      indexym1 = (y-1) * 32;
      indexy = y * 32;
      indexyp1 = (y+1) * 32;
      for (int x = 1; x <= 30; x++)
      {
         sum = aray[indexym1+x-1] + aray[indexym1+x] + aray[indexym1+x+1] + aray[indexy+x-1] + aray[indexy+x+1] + aray[indexyp1+x-1] + aray[indexyp1+x] + aray[indexyp1+x+1];
         if (aray[indexy+x] == 1)
         {
            if ((sum < 2) || (sum > 3))
            {
               newaray[indexy+x] = 0;  // LED could be changed here
            }
            else
            {
               newaray[indexy+x] = 1;
            }
         }
         else
         //if (aray[indexy+x] == 0)
         {
             if (sum == 3)
             {
               newaray[indexy+x] = 1;  // LED could be changed here
             }
             else
             {
               newaray[indexy+x] = 0;
             }
         }
      }
  }
  CheckState();
  Display_8x8();
  delay(delaytime);
}
void Display_8x8()
{
  for (int i=0;i < numarrays; i++)
   {
      /* Clear the display */
      lc1.clearDisplay(i);
      lc2.clearDisplay(i);
      lc3.clearDisplay(i);
      lc4.clearDisplay(i);
   }
  for (int y = 0; y < 8; y++)  // Only the top 8 rows are checked
  {
      indexy = y * 32;
      for (int x = 0; x < 8; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc1.setLed(0, y, x, true);
          }
      }
      
      for (int x = 8; x < 16; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc1.setLed(1, y, x-8, true);
          }
      }
      
      for (int x = 16; x < 24; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc1.setLed(2, y, x-16, true);
          }
      }
      
      for (int x = 24; x < 32; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc1.setLed(3, y, x-24, true);
          }
      }
  }

  for (int y = 8; y < 16; y++)  // second eight rows
  {
      indexy = y * 32;
      for (int x = 0; x < 8; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc2.setLed(0, y, x, true);
          }
      }
      
      for (int x = 8; x < 16; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc2.setLed(1, y, x-8, true);
          }
      }
      
      for (int x = 16; x < 24; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc2.setLed(2, y, x-16, true);
          }
      }
      
      for (int x = 24; x < 32; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc2.setLed(3, y, x-24, true);
          }
      }
  }  

  for (int y = 16; y < 24; y++)  // third eight rows
  {
      indexy = y * 32;
      for (int x = 0; x < 8; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc3.setLed(0, y, x, true);
          }
      }
      
      for (int x = 8; x < 16; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc3.setLed(1, y, x-8, true);
          }
      }
      
      for (int x = 16; x < 24; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc3.setLed(2, y, x-16, true);
          }
      }
      
      for (int x = 24; x < 32; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc3.setLed(3, y, x-24, true);
          }
      }
  }  

  for (int y = 24; y < 32; y++)  // fourth eight rows
  {
      indexy = y * 32;
      for (int x = 0; x < 8; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc4.setLed(0, y, x, true);
          }
      }
      
      for (int x = 8; x < 16; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc4.setLed(1, y, x-8, true);
          }
      }
      
      for (int x = 16; x < 24; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc4.setLed(2, y, x-16, true);
          }
      }
      
      for (int x = 24; x < 32; x++)
      {
          if (aray[indexy+x] == 1)
          {
               lc4.setLed(3, y, x-24, true);
          }
      }
  }    
}

void SeedArray()
{
    randomSeed(analogRead(0));
 //   for (int i=0; i < 576; i++) {aray[i] = 0;}
    for (int a=0; a < 500; a++)
    {
       int y = random(1, 32);
       int x = random(1, 32);
       aray[y*32+x] = 1;
    }
}

void CheckState()
{
  bool flag = true;
  for (int i=0; i < 1024; i++)
  {
    if (aray[i] != newaray[i])
    {
        flag = false;
    }
    lastaray[i] = aray[i];
    aray[i] = newaray[i];
  }
  
  if (flag)
  {
    SeedArray();
  }
  else
  {
       flag = true;
       for (int i=0; i < 1024; i++)
       {
          if (lastaray[i] != newaray[i])
          {
             flag = false;
            
          }
       }
       if (flag) {SeedArray();}
  }
}
6  Using Arduino / LEDs and Multiplexing / Need help with multiple instances of LedControl for 32x32 LED array on: February 07, 2014, 11:09:41 am
Trying to use the LedControl library. I have 16 8x8 LED arrays driven by MAX7219 chips. The units I'm using are found here:

http://www.ebay.com/itm/231109763431?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

The arrangement is to use four LedControl objects, each with four 8x8 displays daisy chained. I tried creating instances like this:

LedControl lc1=LedControl(12,11,10,numarrays);
LedControl lc2=LedControl(12,11,9,numarrays);
LedControl lc3=LedControl(12,11,8,numarrays);
LedControl lc4=LedControl(12,11,7,numarrays);

but this doesn't work. The row with lc1 works OK, but not the others. So it looks like I need completely different pins for all three lines, data, clock and cs. So I try this with just the first two rows:

LedControl lc1=LedControl(12,11,10,numarrays);
LedControl lc2=LedControl(36,34,9,numarrays);

I'm using a Mega 2560 because I need the larger SRAM. This also doesn't work.

What am I doing wrong?

Thanks, Theron Wierenga

7  Using Arduino / Project Guidance / Re: I want to play short .WAV or .MP3 files on: November 18, 2012, 02:34:22 pm
Thanks Grumpy_Mike, I've got one ordered.

Regards, Theron
8  Using Arduino / Project Guidance / I want to play short .WAV or .MP3 files on: November 17, 2012, 06:25:02 pm
I want to add voice to a digital clock, so it will say "one, fifty three" at 1:53. I'm looking for the simplest way
to just read the voice files off an SD card and get the voice out. I don't want the robotic voice of SpeakJet
but am afraid that the overhead of sending bytes to an 8 bit DAC may be too much, edpecially when reading
 from the SD card.

Any suggestions?

Thanks,

Theron Wierenga
9  Using Arduino / Programming Questions / Using SD library with analog pins on: November 15, 2012, 07:07:13 pm
I'm running out of pins, so I want to use the analog pins as digital for the SD library

Normal       My choice
pin 10          pin 15, A1 for CS
pin 11          pin 16, A2 for MOSI
pin 13          pin 17, A3 for SCK
pin 12          pin 18, A4 for MISO

I changed these pin assignments in the pins_arduino.h file which appears to set them, but my sample code does not initialize the SD library.

Any suggestions? I suspect I need other changes deep in the library. Here's my code.

Thanks, Theron Wierenga


#include <SD.h>

File myFile;

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
   pinMode(10, OUTPUT);
   pinMode(15, OUTPUT);    // CS or SS
   pinMode(16, OUTPUT);    // MOSI
   pinMode(17, OUTPUT);    // SCK clock
   pinMode(18, INPUT);     // MISO
     
   
  if (!SD.begin(15)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile = SD.open("test_new.txt", FILE_WRITE);
 
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
 
  // re-open the file for reading:
  myFile = SD.open("test_new.txt");
  if (myFile) {
    Serial.println("test.txt:");
   
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
        Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop()
{
    // nothing happens after setup
}
10  Using Arduino / Programming Questions / Significance of color of text in a sketch on: October 27, 2012, 08:57:42 am
I've been unable to find documentation of the color of text in a sketch. Brown looks like reserved words, blue is text, etc. Here are my questions about the two code fragments. Why are LiquidCrystal.h and Wire.h brown and the other two includes black? Why is minute brown, while hour and second are black. This last one seems to be giving me a problem.

My RTC is on battery but minute gives a new value when the Arduino board is powered up.


#include <LiquidCrystal.h>
#include <DS1307RTC.h>  // a basic DS1307 library that returns time as a time_t
#include <Time.h> 
#include <Wire.h

lcd.setCursor(0, 1);
lcd.print(hour());
lcd.print(" ");
lcd.print(minute());
lcd.print(" ");
lcd.print(second());
lcd.print("  ");

Pages: [1]