PCB has set of 7 switches connected to IO
Printing them out serially for debugging
One of them has a IO show up that is a 3 now and then
The others, show up as 1 as switch depressed
// E21-003 Collimator Recognition
//Microcontroller being used is Leonardo variant
//polulu astar 3101 https://www.pololu.com/product/3101
//It is reading the configuration of switches off the PCB E33-031 via the E11-033 - Collimator Recognition Cable
//There are 7 switches on the collimator recognition PCB
//The mapping of hte Collimator recogntion Pins, through cable, to the Leo PCB is as follows
// Coll_PCB_SW1-> Cable#1 -> Leo#0
// Coll_PCB_SW2 -> Cable#3 -> Leo#1
// Coll_PCB_SW3 -> Cable#5 -> Leo#4
// Coll_PCB_SW4 -> Cable#7 -> Leo#7
// Coll_PCB_SW5 -> Cable#9 -> Leo#8
// Coll_PCB_SW6 -> Cable#10 -> Leo#18 (or 19)
// Coll_PCB_SW7 -> Cable#8 -> Leo#19 (or 18)
/***Definitions***/
#define Pin0 0
#define Pin1 1
#define Pin4 4
#define Pin7 7
#define Pin8 8
#define Pin18 18
#define Pin19 19
//***Constants***//
byte SwitchArray[7] = {0, 0, 0, 0, 0, 0, 0};
int arraySize = sizeof(SwitchArray) / sizeof(SwitchArray[0]);
void setup()
{
Serial.begin(9600);
pinMode(Pin0,INPUT);
pinMode(Pin1,INPUT);
pinMode(Pin4,INPUT);
pinMode(Pin7,INPUT);
pinMode(Pin8,INPUT);
pinMode(Pin18,INPUT);
pinMode(Pin19,INPUT);
}
void loop()
{
delay(400);
SwitchArray[1] = digitalRead(Pin0);
SwitchArray[2] = digitalRead(Pin1);
SwitchArray[3] = digitalRead(Pin4);
SwitchArray[4] = digitalRead(Pin7);
SwitchArray[5] = digitalRead(Pin8);
SwitchArray[6] = digitalRead(Pin19);
SwitchArray[7] = digitalRead(Pin18);
//print the array out, has to be done each element at a time
//then do a println to start a new line to repeat it
for (int i = 1; i < arraySize+1; i++)
{
Serial.print(SwitchArray[i]); // Print the variable and move to the next
}
Serial.println(); // create a new line
}
type or paste code here
// E21-003 Collimator Recognition
//Microcontroller being used is Leonardo variant
//polulu astar 3101 https://www.pololu.com/product/3101
//It is reading the configuration of switches off the PCB E33-031 via the E11-033 - Collimator Recognition Cable
//There are 7 switches on the collimator recognition PCB
//The mapping of hte Collimator recogntion Pins, through cable, to the Leo PCB is as follows
// Coll_PCB_SW1-> Cable#1 -> Leo#0
// Coll_PCB_SW2 -> Cable#3 -> Leo#1
// Coll_PCB_SW3 -> Cable#5 -> Leo#4
// Coll_PCB_SW4 -> Cable#7 -> Leo#7
// Coll_PCB_SW5 -> Cable#9 -> Leo#8
// Coll_PCB_SW6 -> Cable#10 -> Leo#18 (or 19)
// Coll_PCB_SW7 -> Cable#8 -> Leo#19 (or 18)
//***Constants***//
const byte arraySize = 7;
const byte SwitchArray[arraySize] = {0, 1, 4, 7, 8, 18, 19};
void setup()
{
Serial.begin(9600);
//Not necessary to set pins to INPUT because that is the default mode
}
void loop()
{
delay(400);
//print the array out, has to be done each element at a time
//then do a println to start a new line to repeat it
for (int i = 0; i < arraySize; i++)
{
Serial.print(digitalRead(SwitchArray[i])); // Print the variable and move to the next
}
Serial.println(); // create a new line
}
/***Definitions***/
#define Pin0 0
#define Pin1 1
#define Pin4 4
#define Pin7 7
#define Pin8 8
#define Pin18 18
#define Pin19 19
//***Constants***//
int collimator = 0; //initialize to nonvalid number
int valid_filter = 0; //initialize
byte SwitchArray[7] = {0, 0, 0, 0, 0, 0, 0}; //bounds starts at 0
int arraySize = sizeof(SwitchArray) / sizeof(SwitchArray[0]);
void setup()
{
Serial.begin(9600);
pinMode(Pin0,INPUT);
pinMode(Pin1,INPUT);
pinMode(Pin4,INPUT);
pinMode(Pin7,INPUT);
pinMode(Pin8,INPUT);
pinMode(Pin18,INPUT);
pinMode(Pin19,INPUT);
}
void loop()
{
delay(400);
SwitchArray[0] = digitalRead(Pin0);
SwitchArray[1] = digitalRead(Pin1);
SwitchArray[2] = digitalRead(Pin4);
SwitchArray[3] = digitalRead(Pin7);
SwitchArray[4] = digitalRead(Pin8);
SwitchArray[5] = digitalRead(Pin19);
SwitchArray[6] = digitalRead(Pin18);
//print the array out, has to be done each element at a time
//then do a println to start a new line to repeat it
for (int i = 0; i < arraySize; i++)
{
Serial.print(SwitchArray[i]); // Print the variable and move to the next
}
Serial.println(); // create a new line
}