Setting a char equal to the val of a char*?

So, you have to set arrays of strings as such:

char* myPins[]={"LED9", "LED8", "LED7", "LED10"};

But then how do you actually get to use the value? Trying

currPin=myPins[1];, where currPin is a char yields this error:" error: incompatible types in assignment of 'char' to 'char* [1]"

Thoughts? Seems like a simple type mismatch, but I'm not sure how to fix it. Basically: How can I set a char equal to the value of charArray[x]?

Basically: How can I set a char equal to the value of charArray[x]?

Wrong question. You are asking "How can I set an 8-bit integer equal to a 16-bit pointer"?

A "char" is just that: an 8-bit integer. A pointer (char *) is a 16-bit integer. What you REALLY want to do (it appears) is extract one of the STRINGS (char *) from the array. So you could write:

char *currPin;
...
currPin = myPins[1];
...

Ah. Thanks! Well, new question. Here’s the code:

//IDEA: Light Cacaphony
//Random LED, Random Times, (Random Delay?)

#define LED11 11
#define LED10 10 //Syntax being, #define NAME pin#
#define LED9 9
#define LED8 8
#define LED7 7
//HOW DO I GET THE CHAR VAL OF A CHAR*?!
char* myPins[]={"LED9", "LED9", "LED9", "LED9"};


int randNumber=0;
int i=0;

void setup(){
 pinMode (LED9, OUTPUT);
 pinMode (LED10, OUTPUT);
}

void loop(){
randNumber = random(0, 3);  
char *currPin=myPins[randNumber];  
  fade(currPin);
}

Where fade() is currently set up to accept a char. Changing it to a char* as below:

//SETUP: Fade is i/o cycle, breatheIN is what it says, breatheOut is the opp.
void fade(char *ledID){
   for(i = 0; i<255; i++){
    analogWrite(ledID,i);
    delay(10);
 }

Yields the following predictable error: "
In function ‘void fade(char*)’:
error: invalid conversion from ‘char*’ to 'uint8_t"

What’s the solution here? I need a char, I have a char*.

The parameter to analogWrite() is an integer. So you have to pass an integer to fade():

void fade(int ledID){
   for(i = 0; i<255; i++){
    analogWrite(ledID,i);
    delay(10);
 }
...
{
   fade(LED9);
}

Really not seeing what you array of strings has to do with it.

OH! OK, I went back to look at your original post. You don't want an array of strings; you want an array of integers:

int myPins[]={LED9, LED9, LED9, LED9};
void setup(){
 pinMode (LED9, OUTPUT);
 pinMode (LED10, OUTPUT);
}
void loop(){
  int randNumber = random(0, 3);
  int currPin=myPins[randNumber];
  fade(currPin);
}

Aha. I didn't think it was okay to have characters in an array of integers. Thanks, I'll play with this this evening.

I didn’t think it was okay to have characters in an array of integers

No, nothing wrong with characters in "int"s, but you had strings. :wink: