Problem with referencing arrays. Invalid char to int conversion

Hi everyone. This is one that's stopped me cold. The code that I have here is for a POV clock using a ds1307 chip. No problems with getting Ard to talk to the ds1307 chip. I've used some code from another programmer (m. zoellner) that created a POV wand using 5 LEDs. My clock will have 8 LEDS and so I've created a set of arrays that graphically depict the numbers 0 - 9 on the top of the swing of the rotor and again another set of arrays that do the same for the bottom of the swing. You'll see these arrays at the top of the code. The arrays cannot be named by the number they represent however as this is not allowed in syntax of this coding. Thus I've had to represent them with a letter. Where the problem comes in is when I receive a number (you'll see in this current version of coding it's the seconds I'm trying to convert and display) from the ds1307 chip, I must change this numerical value to a letter value that will reference the corresponding array. This is done using two additional arrays called "stringaS" and "stringbS". This letter value then is sent into a function called either printNumTop or printNumBot. Well these functions do not like the char value that is being sent to them and I can't figure out how to get around this. I consistently get an error message that says "invalid conversion from char to int" when I try to compile the code.
.
Here's my code:

// POVNo!1

#include "Wire.h" // These declarations are for the DS1307 clock chip
#define DS1307_I2C_ADDRESS 0x68 // This is the I2C address
// These declarations are for the DS1307 clock chip

#define LEDIR 2 // Infared LED
// ******************* Top Number Arrays ********************************
int a_[] = {0,0,0,0,0,0,0,0, 0,0,1,0,0,1,0,0, 0,0,0,0,0,0,0,0}; // _
int a[] = {0,1,0,0,0,0,0,1, 1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,1}; // 1
int b[] = {0,1,0,0,1,1,1,1, 1,0,0,0,1,0,0,1, 0,1,1,1,1,0,0,1}; // 2 the actual digit graphic. These are given letter values because
int c[] = {0,1,0,0,1,0,1,0, 1,0,0,0,1,0,0,1, 0,1,1,1,1,1,1,0}; // 3 Arduino will not accept a number (ie "1", "2", etc) name in coding
int d[] = {1,1,1,1,0,0,0,0, 0,0,0,1,0,0,0,0, 1,1,1,1,1,1,1,1}; // 4
int e[] = {1,1,1,1,0,0,0,1, 1,0,0,1,0,0,0,1, 1,0,0,1,1,1,1,1}; // 5
int f[] = {0,1,1,1,1,1,1,0, 1,0,0,0,1,0,0,1, 0,1,0,0,0,1,1,0}; // 6 TOP OF CLOCK NUMBERS
int g[] = {1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0}; // 7
int h[] = {0,1,1,0,1,1,1,0, 1,0,0,1,0,0,0,1, 0,1,1,0,1,1,1,0}; // 8
int i[] = {0,1,1,1,1,1,1,0, 1,0,0,1,0,0,0,1, 0,1,1,0,0,0,1,0}; // 9
int j[] = {1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,1, 1,1,1,1,1,1,1,1}; // 0
// ************** Bottom Number Arrays *********************************
int l[] = {0,0,0,0,0,0,0,1, 1,1,1,1,1,1,1,1, 0,1,0,0,0,0,0,1}; // 1
int m[] = {0,1,1,1,1,0,0,1, 1,0,0,0,1,0,0,1, 0,1,0,0,1,1,1,1}; // 2
int n[] = {0,1,0,0,1,0,1,0, 1,0,0,0,1,0,0,1, 0,1,1,1,1,1,1,0}; // 3
int o[] = {1,1,1,1,0,0,0,0, 0,0,0,1,0,0,0,0, 1,1,1,1,1,1,1,1}; // 4 BOTTOM OF CLOCK NUMBERS
int p[] = {1,1,1,1,0,0,0,1, 1,0,0,1,0,0,0,1, 1,0,0,1,1,1,1,1}; // 5
int q[] = {0,1,1,1,1,1,1,0, 1,0,0,0,1,0,0,1, 0,1,0,0,0,1,1,0}; // 6
int r[] = {1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0}; // 7
int s[] = {0,1,1,0,1,1,1,0, 1,0,0,1,0,0,0,1, 0,1,1,0,1,1,1,0}; // 8
int t[] = {0,1,1,1,1,1,1,0, 1,0,0,1,0,0,0,1, 0,1,1,0,0,0,1,0}; // 9
int u[] = {1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,1, 1,1,1,1,1,1,1,1}; // 0
// *********************************************************************
// *************** Graphics Variables ********************************
int val = 0;
int numspace = 2;
int dottime =1;
char stringaS[11]={'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'}; // Top of Clock array replacement values
char stringbS[11]={'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u'}; // Bottom of Clock array replacement values
// *************** Time Keeping Variables *****************************
int hour1, mins1, seconds, FirstDigSec, SecondDigSec, FirstDigMin, SecondDigMin, FirstDigHr, SecondDigHr;
byte second, minute, hour, second2;
// *********************************************************************
void setup() {
Wire.begin(); // To talk with the clock
Serial.begin(9600); // To talk with serial input/output
pinMode(5, OUTPUT); // These are the eight LED's on the rotor
pinMode(6, OUTPUT); //
pinMode(7, OUTPUT); //
pinMode(8, OUTPUT); //
pinMode(9, OUTPUT); //
pinMode(10, OUTPUT); //
pinMode(11, OUTPUT); //
pinMode(12, OUTPUT); //
pinMode(LEDIR, INPUT); // this is the Infrared sensor on the rotor
}
// ************************************ Decimal to Binary Conversion **********************************
byte decToBcd(byte val)
{
return ( (val/1016) + (val%10) );
}
// ************************************ Binary to Decimal Conversion **********************************
byte bcdToDec(byte val)
{
return ( (val/16
10) + (val%16) );
}
// ********************************* Get the time from the DS1307 chip *******************************
void getTimeDs1307() { // Reset the register pointer
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0x00);
Wire.endTransmission();

Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

second = bcdToDec(Wire.receive() & 0x7f);
// minute = bcdToDec(Wire.receive() & 0x8);
// second2 = bcdToDec(Wire.receive() & 0x8f);
// minute = bcdToDec(Wire.receive());
hour = bcdToDec(Wire.receive() & 0x3); // Need to change this if 12 hour am/pm
}
// *************************************** Top Number Display *******************************************
void printNumTop(int numbr[]) {
int y;
// printing the 1st row of the number
for (y = 0; y < 8; y++) {
//for (y = 7; y > 0; y--) {
digitalWrite(12 - y, numbr[y]);
}
delay(dottime);
// printing the 2nd row of the number
for (y = 0; y < 8; y++) {
digitalWrite(12 - y, numbr[y+8]);
}
delay(dottime);
// printing the 3rd row of the number
for (y = 0; y < 8; y++) {
digitalWrite(12 - y, numbr[y+16]);
}
delay(dottime);
for (y = 0; y < 8; y++) {
digitalWrite(y + 5, 0);
}
delay (numspace);
}
// ************************* Bottom Number Display *********************************************************
void printNumBot(int numbr[]) {
int y;
// printing the 1st row of the number
for (y = 0; y < 8; y++) {
digitalWrite(y + 5, numbr[y]);
}
delay(dottime);
// printing the 2nd row of the number
for (y = 0; y < 8; y++) {
digitalWrite(y + 5, numbr[y+8]);
}
delay(dottime);
// printing the 3rd row of the number
for (y = 0; y < 8; y++) {
digitalWrite(y + 5, numbr[y+16]);
}
delay(dottime);
for (y = 0; y < 8; y++) {
digitalWrite(y + 5, 0);
}
delay (numspace);
}
// ****************************************************************************************************************

void loop(){
getTimeDs1307(); // Get the current time

hour1 = hour;
mins1 = minute;
seconds = second;
SecondDigSec = second2;
if (seconds < 10 && seconds >= 0) { // These next 6 "if" statements create the 1st and 2nd digit values
FirstDigSec = 0; // of the seconds display.
SecondDigSec = (seconds - 0);
}
if (seconds < 20 && seconds >= 10) {
FirstDigSec = 1;
SecondDigSec = (seconds - 10);
}
if (seconds < 30 && seconds >= 20) {
FirstDigSec = 2;
SecondDigSec = (seconds - 20);
}
if (seconds < 40 && seconds >= 30) {
FirstDigSec = 3;
SecondDigSec = (seconds - 30);
}
if (seconds < 50 && seconds >= 40) {
FirstDigSec = 4;
SecondDigSec = (seconds - 40);
}
if (seconds < 60 && seconds >= 50) {
FirstDigSec = 5;
SecondDigSec = (seconds - 50);
}
// Serial.println(hour1); // only here for test purposes
// Serial.println(mins1); // only here for test purposes
// Serial.println(stringaS[SecondDigSec]); // only here for test purposes
// delay(500); // this line in particular must be commented out to work
val = digitalRead(LEDIR);
if (val == LOW){
printNumBot(stringbS[FirstDigSec]); // print the bottom numbers first becuase the IR sensor is at the 5 oclock position
printNumBot(stringbS[SecondDigSec]); // ditto
// delay(15);
// printNumTop(stringaS[FirstDigSec]); // now print the top numbers
// printNumTop(stringaS[SecondDigSec]); // ditto
}
}
// ************************* END *************************************************
A lenthy problem if you can understand my question. Run the code and you'll see what problem is arising here. Thanks for your input and help.
.
Tim

Can you please edit your post and make the code part a "code" block? (Hit the # button on the forum).

Well you are doing exactly what the compiler says you are doing. You have a function printNumTop that expects an array of integers, and you are passing it a char (eg. 'a').

void printNumTop(int numbr[]) {

You basically can't convert from 'a' (a value) into a (a data name).

You really want something like a 2-dimensional array. One dimension is the characters you are displaying (eg. '1', '2', '3') and the other dimension is the bits which represent them. Something along these lines:

byte font [10] [5]  = {
     
  { 0x3E, 0x51, 0x49, 0x45, 0x3E }, // 0 
  { 0x00, 0x42, 0x7F, 0x40, 0x00 }, // 1
  { 0x42, 0x61, 0x51, 0x49, 0x46 }, // 2
  { 0x21, 0x41, 0x45, 0x4B, 0x31 }, // 3
  { 0x18, 0x14, 0x12, 0x7F, 0x10 }, // 4
  { 0x27, 0x45, 0x45, 0x45, 0x39 }, // 5
  { 0x3C, 0x4A, 0x49, 0x49, 0x30 }, // 6
  { 0x01, 0x71, 0x09, 0x05, 0x03 }, // 7
  { 0x36, 0x49, 0x49, 0x49, 0x36 }, // 8
  { 0x06, 0x49, 0x49, 0x29, 0x1E }, // 9
 
 };

In this example we have 5 bytes per character, which gives us 5 pixels along and 8 down (the 8 bits in each byte). This was for an LCD display.

Now to display each byte you do something like this:

byte c = 2;  // which number

// for each column ...
for (byte x = 0; x < 5; x++)
    display (font [c] [x]);

So basically the display function takes the 8 bits and writes them (so you delay a suitable amount and then do the next one).

Hi Nick, thanks for your in depth response.... I'm still not sure if I understand how that two dimensional array works. I think I'm going to have to look at it for a while to understand it.
.
Going further though, why would the original code from M. Zoellner work with a constant value to be sent to those functions? Here's his code on his POV wand project that I used, I think you'll recognize most of the lines here with different variables placed in:

void printLetter(int letter[])
{
 int y;
 
 // printing the first y row of the letter
 for (y=0; y<5; y++)
 {
   digitalWrite(y+2, letter[y]);
 }
 delay(dotTime);
 
 // printing the second y row of the letter
 for (y=0; y<5; y++)
 {
   digitalWrite(y+2, letter[y+5]);
 }
 delay(dotTime);
 
 // printing the third y row of the letter
 for (y=0; y<5; y++)
 {
   digitalWrite(y+2, letter[y+10]);
 }
 delay(dotTime);
 
 // printing the sspace between the letters
 for (y=0; y<5; y++)
 {
   digitalWrite(y+2, 0);
 }
 delay(letterSpace);
}

void loop()
{
 // printing some letters
 printLetter(N);
 printLetter(E);
 printLetter(R);
 printLetter(D);
 printLetter(S);
 printLetter(_);
}

When he calls the function "printLetter()", he's placing a letter in there. How is this different then what I'm doing? BTW my code actually works if you do hard type a letter in the function as opposed to letting a my one dimensional array place it in there.
.
I tried putting my copied code in like you said by pushing the button.... We'll see how this works now
.
Thank you for your help.
.
Tim

The issue you have is that the function wants a pointer but you're not giving it a pointer. This is not a problem of converting a char to an int, that would work. Its a problem of converting a value to a pointer. That won't work. You have a few options to get it to compile, although I expect it won't run correctly.

First, change the function to take a pointer to a char instead of an int then pass it the address, like this:

void printNumBot(char numbr[]) {

Then pass the address instead of the value like this:

printNumBot(&stringbS[FirstDigSec]); // print the bottom numbers first becuase the IR sensor is at the 5 oclock position
printNumBot(&stringbS[SecondDigSec]); // ditto

That makes it compile, BUT your printNumBot function, after a very quick glance, seems to be iterating over what it expects to be an array of values (in this case ints but you're better off using a smaller type like a char). I see you declared a bunch of arrays at the top with data, so it looks like what you should be doing is something like

printNumBot(a)

or

printNumBot(c)

This passes the address of the base of the array to your printNumBot function, which then iterates over it doing the digital writes to control the segments.

If I declare an array like this:

int b[] = {0,1,0,0,1,1,1,1, 1,0,0,0,1,0,0,1, 0,1,1,1,1,0,0,1};

then b is a pointer that refers to the base of an array. b[0] is the value of the first element of the array, NOT its address (and therefor not a pointer). If I want the address of the first element so I can pass it as a pointer I can do this: &b[0] but you don't want that.

So when you do this:

printNumBot(b)

you are sending an address of the base of the b array to the function. My guess is that would work but not do what you want exactly.

Do you follow?

Skyjumper,
.
That business of using "&" when referencing my functions (ie: printNumBot(&stringbS[SecondDigSec]) has gotten me much closer! and I did change it to a char on the actual function. Your advice is priceless. My graphics aren't coming out quite right just yet but you can see the digits changing on the spinning rotor. I'll keep you posted.
.
Thank you dearly!
.
Tim

Good luck Tim. You may want to have a look at this when you have a minute:

If you get stuck again let us know.