I want set up my arduino's analog pins as digital pins in one shot with a for loop but I get an error in my array.
down below is my code and below my code is the error I get
My code
// including keyboard.h library for the keybard functions
#include <Keyboard.h>
// setting Arrays for looping later
int myIntPins[12] = {2,3,4,5,6,7,8,9,10,11,12,13};
int myChar[12] = {97, 98, 99, 100, 101,102,103,104,105,106,107,108};
int myChar2[6] = {109,110,111,112,113,114};
myCharPins[6] = {"A0","A1","A2","A3","A4","A5"};
int a;
int x;
int i;
void setup() {
// put your setup code here, to run once:
//Setting up Digital Pins
for (int i=0; i <= 11; i=i+a){
pinMode(myIntPins[i],INPUT);
}
//pinMode(2, INPUT);
//pinMode(3, INPUT);
//pinMode(4, INPUT);
//pinMode(5, INPUT);
//pinMode(6, INPUT);
//pinMode(7, INPUT);
//pinMode(8, INPUT);
//pinMode(9, INPUT);
//pinMode(10, INPUT);
//pinMode(11, INPUT);
//pinMode(12, INPUT);
//pinMode(13, INPUT);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// setting up Analog Pins to Digital
for (int x=0; x <= 5; x=x+a){
pinMode(myCharPins[x],INPUT);
}
//pinMode(A0,INPUT);
//pinMode(A1,INPUT);
//pinMode(A2,INPUT);
//pinMode(A3,INPUT);
//pinMode(A4,INPUT);
//pinMode(A5,INPUT);
// starting keyboard
Keyboard.begin();
}
void loop() {
// put your main code here, to run repeatedly:
//if pin 2 is pressed then send the a key/char
// if (digitalRead(2) == LOW) {Keyboard.write(97);}
// instead of doing an if one by one doing a loop all in one shot
// this loop for regular digital pins
a=1;
for (int i=0; i <= 11; i=i+a){
if (digitalRead(myIntPins[i]) == LOW){
Keyboard.write(myChar[i]);
}
}
a=1;
// this loop for the analog pins now working as digital pins
for (int x=0; x <= 5; x=x+a){
if (digitalRead(myCharPins[x]) == LOW){
Keyboard.write(myChar2[x]);
}
}
delay(10);
}
error
Arduino: 1.8.7 (Windows 10), Board: "Arduino Leonardo"
Mandar_Keyboard_Key_1:10:2: error: 'myCharPins' does not name a type
myCharPins[6] = {"A0","A1","A2","A3","A4","A5"};
^
C:\Users\manue\OneDrive\Documents\Arduino\Mandar_Keyboard_Key_1\Mandar_Keyboard_Key_1.ino: In function 'void setup()':
Mandar_Keyboard_Key_1:45:11: error: 'myCharPins' was not declared in this scope
pinMode(myCharPins[x],INPUT);
^
C:\Users\manue\OneDrive\Documents\Arduino\Mandar_Keyboard_Key_1\Mandar_Keyboard_Key_1.ino: In function 'void loop()':
Mandar_Keyboard_Key_1:77:21: error: 'myCharPins' was not declared in this scope
if (digitalRead(myCharPins[x]) == LOW){
^
exit status 1
'myCharPins' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.