Sorry, I'm a super newbie in over my head here. This is probably a stupid question, but is there a limit to the amount of sensors I can use at one time on this board? I will post some code below, but I have ten reed switches on pins 1-10. For some reason, It will not read the sensor on pin 1 or pin 10... in constantly thinks that they are 'HIGH'. Is this just bad connections, a short, or something more. I didn't know if the fact that arduino was 8 bit was the reason. Just seems odd that I stopped at 8. Below is the code. Sorry for the stupid question. It won't even work with simple code like this:
#define LED 13 // pin for LED
#define BUTTON1 1 // the input pin for the button
#define BUTTON2 2 // the input pin for the button
#define BUTTON3 3 // the input pin for the button
#define BUTTON4 4 // the input pin for the button
#define BUTTON5 5 // the input pin for the button
#define BUTTON6 6 // the input pin for the button
#define BUTTON7 7 // the input pin for the button
#define BUTTON8 8 // the input pin for the button
#define BUTTON9 9 // the input pin for the button
#define BUTTON10 10 // the input pin for the button
int val1 = 0; //val will be used to store the state of the input pin
int val2 = 0; //val will be used to store the state of the input pin
int val3 = 0; //val will be used to store the state of the input pin
int val4 = 0; //val will be used to store the state of the input pin
int val5 = 0; //val will be used to store the state of the input pin
int val6 = 0; //val will be used to store the state of the input pin
int val7 = 0; //val will be used to store the state of the input pin
int val8 = 0; //val will be used to store the state of the input pin
int val9 = 0; //val will be used to store the state of the input pin
int val10 = 0; //val will be used to store the state of the input pin
void setup() {
pinMode(LED, OUTPUT); //sets led as an output
pinMode(BUTTON1, INPUT); //button is input
pinMode(BUTTON2, INPUT); //button is input
pinMode(BUTTON3, INPUT); //button is input
pinMode(BUTTON4, INPUT); //button is input
pinMode(BUTTON5, INPUT); //button is input
pinMode(BUTTON6, INPUT); //button is input
pinMode(BUTTON7, INPUT); //button is input
pinMode(BUTTON8, INPUT); //button is input
pinMode(BUTTON9, INPUT); //button is input
pinMode(BUTTON10, INPUT); //button is input
}
void loop() {
val1 = digitalRead(BUTTON1); // read input value and store it
val2 = digitalRead(BUTTON2); // read input value and store it
val3 = digitalRead(BUTTON3); // read input value and store it
val4 = digitalRead(BUTTON4); // read input value and store it
val5 = digitalRead(BUTTON5); // read input value and store it
val6 = digitalRead(BUTTON6); // read input value and store it
val7 = digitalRead(BUTTON7); // read input value and store it
val8 = digitalRead(BUTTON8); // read input value and store it
val9 = digitalRead(BUTTON9); // read input value and store it
val10 = digitalRead(BUTTON10); // read input value and store it
//execute code based on the value
if (val1 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val2 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val3 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val4 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val5 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val6 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val7 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val8 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val9 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
if (val10 == HIGH) {
digitalWrite(LED, HIGH); // if button is pressed, turn on LED
} else {
digitalWrite(LED, LOW); // no press, LEd off
}
}