Hello All. I've been doing some reading on C++ recently as a total newcomer to the language and Arduino. I got to the point in my reading that I sensed I ought to get my hands dirty in order to truly understand and reinforce some of what I was attempting to grasp. As an exercise, I want to map the analog input from a fuel gauge sending unit and have the Arduino outputs energize one of nine leds relative to the range of 'empty' to 'full'. The nine leds will be controlled as a matrix using 6 Arduino outputs. Right now I'm working on the output. The code I've come up with so far is below. Can an text from an array be used for this? I also thought that I might be able to use 1 and 0 in place of HIGH and LOW but I couldn't find any information that allowed me to think that that may be possible.
char* led_matrix [9] [6] = {
{LOW, HIGH, HIGH, HIGH, LOW, LOW}
{HIGH, LOW, HIGH, HIGH, LOW,LOW}
{HIGH, HIGH, LOW, HIGH, LOW, LOW}
{LOW, HIGH, HIGH, LOW, HIGH, LOW}
{HIGH, LOW, HIGH, LOW, HIGH, LOW}
{HIGH, HIGH, LOW, LOW, HIGH, LOW}
{LOW, HIGH, HIGH, LOW, LOW, HIGH}
{HIGH, LOW, HIGH, LOW, LOW, HIGH}
{HIGH, HIGH, LOW, LOW, LOW, HIGH}
};
void setup()
{
pinMode (Wire1Pin, OUTPUT);
pinMode (Wire2Pin, OUTPUT);
pinMode (Wire3Pin, OUTPUT);
pinMode (Wire4Pin, OUTPUT);
pinMode (Wire5Pin, OUTPUT);
pinMode (Wire6Pin, OUTPUT);
}
void loop()
int sequence;
for(sequence = 0, <9, sequence++)
{
digitalWrite (Wire1Pin, led_matrix [sequence] [0]);
digitalWrite (Wire2Pin, led_matrix [sequence] [1]);
digitalWrite (Wire3Pin, led_matrix [sequence] [2]);
digitalWrite (Wire4Pin, led_matrix [sequence] [3]);
digitalWrite (Wire5Pin, led_matrix [sequence] [4]);
digitalWrite (Wire6Pin, led_matrix [sequence] [5]);
}
Looking forward to opinions and learning even more. - Scotty