I expect the Arduino MEGA 2560 (my first introduction to the Arduino family) to be delivered in a few days. I don't need a lot of processing capability, but I do need a bunch of digital I/O lines.
I need to load a two dimensional array with a bunch of integers, 0 to 5. This processor will not be connected to a PC so the data has to be on board in the EEPROM memory or in the code - like the 'DATA" statement in old versions of BASIC. I can see a couple of inelegant ways to approach this by manipulating a char array, but I need a way to verify that by whatever means I read in the data, it can be retrieved correctly. I've built a circuit that shows the address and data lines with LEDs, but I don't see a way to stop the program so I can read them. If you ever tried to read the lights on an IBM 1620 you'd know what I mean - yes, I'm over 70.
I'd be happy to just print some debug statements to that error bar at the bottom of the IDE and set some break points, but I haven't found the commands for such a task.
hacketet:
I'd be happy to just print some debug statements to that error bar at the bottom of the IDE and set some break points, but I haven't found the commands for such a task.
many choose to use the serial monitor and insert
Serial.println(whatYouWatToPrint);
statement sprinkled through key areas of their code...
hacketet:
I'd be happy to just print some debug statements to that error bar at the bottom of the IDE and set some break points, but I haven't found the commands for such a task.
If you want to direct serial output to different parts of the serial monitor screen, you have to use a PC resident terminal emulator program like putty or Tera Term. Then you can use ANSI escape sequences to send cursor commands. But you have to roll your own code to do it.
What is a "bunch" of integers? Is the "bunch" filled with constnats? See if the PROGMEM directive would be of help.
Here are a couple sections of code I'm presently working on which I think answer a couple of your questions.
To load data into an array, you can set the values at the time the array is declared.
const long MAX_SPEED[] = {32, 32, 16};
const long ACCELERATION[] = {2, 2, 1}
You can do the same with two dimensional arrays.
You don't have to declare the array size if you're filling the array.
This is how I add breakpoints.
boolean waitForPressFlag = 1;
void pressToContinue()
{
if (waitForPressFlag)
{
Serial.println(F("Press enter key to continue."));
while (Serial.available() == 0) {}
checkOtherInput();
}
}
void checkOtherInput()
{
while (Serial.available() > 0)
{
byte inputCharacter = Serial.read();
if (inputCharacter == 'x') // toggle pause for input
{
if (waitForPressFlag)
{
waitForPressFlag = 0;
}
else
{
waitForPressFlag = 1;
}
}
}
}
The variable "waitForPressFlag" can be turned on and off by entering "x" (and the enter key).
I adding "pressToContinue();" to my code wherever I want a breakpoint.
There are likely better ways to pause a program and hopefully someone will let us know about these better ways.
If you need "a bunch" of digital I/O lines, have a look at using shift registers. I hadn't done any electronics building before, but I found that wiring a few of these up was pretty simple, and built myself a 4*8 LED grid. Just because
. They are 5 bucks, and each one will convert 8 inputs into a single input, or 8 outputs into a single output (be sure you get the right ones for what you are trying to do). And you can chain them
.
If you have a lot of static data that needs to go into an array (eg, a character set for a display), you will need to use PROGMEM. And you will want to encode your data in such a away that you are not wasting bits. This means that you have to spend cycles decodng the packed data - but them's the breaks. All computing involves a space vs. time tradeoff.