Hello! First post here! I'm very new to Arduino and programming in general, and I'm enrolled in an introductory course that has me slamming my head against the wall.
I'm seeking help in understanding how some code should be formatted for an assignment.
I need to write a program that:
- globally declares an array of size fifteen. The array data type is int.
- write a function that fills the array with random values in the range [low, high]. This function has two parameters: low, high.
- write a function that serially transmits the array data. This function has one parameter that controls the number of array elements printed on the same line.
- In the loop function, call the function that fills the array with random values and then call the print array function. Each time through the loop, the array is filled with random values and then serially transmitted (printed).
This seems like it should be easy! I believe I have a rough idea of how this all goes together, but I keep getting errors like:
... not declared in this scope
This is the code I've got so far:
// Create an array size 15
int A_ray[15];
void setup()
{
Serial.begin(9600); // Baud rate: 9600
}
void loop()
{
fill_Array() // Access fill_Array
print_Array() // Access print_Array
}
int fill_Array( low , high ) // I want low and High to be 0 and 25
{
A_ray[15] = random(0,26); // Fill A_ray with random numbers 0 through 25
}
void print_Array(void)
{
Serial.println(A_ray[15]); // serially prints array in a matrix fromat
}
I'm not sure how to implement the functions and their parameters to get the serial output. In the examples, I've been provided this is how it looks but I'm not sure of my functions. Please help me get this program running!