Hi everybody
I need to ask somethig, I want to turn on 6 leds, evey one has his own switch (attached pictures), you do not care about the white button, when I reach to turn on the leds I going to give it his userful funtion
On the right you can see the pin`s leds
Over here, you can see the tracks connections, the led share negative tracks current, the switches share 5V current. I test it with a tester on the tracks, nothings is wrong in there,the switches open and close the circuit when I press them.
Leds are in HIGH status, to prove how that circuit works.
This is the idea: when I press shk1 must turn on Led1, and successively with the others till shk6;Led6. In this moment I press , e.g, the shk1 I can not turn on the Led1.
I do not know that I am doing wrong, could you help me please.
P.D: Sorry for my english if I wrote it incorrectly.
//Declaración de Leds
int Led1=8; //Led delantero Izquierdo
int Led2=9; //Led delantero Derecho
int Led3=10; //Led central Izquierdo
int Led4=11; //Led central Derecho
int Led5=12; //Led trasero Izquierdo
int Led6=13; //Led trasero Derecho
//Declaración de sensores de impacto
int shk1=2; //Sensor delantero Izquierdo
int shk2=3; //Sensor delantero Derecho
int shk3=4; //Sensor central Izquierdo
int shk4=5; //Sensor central Derecho
int shk5=6; //Sensor trasero Izquierdo
int shk6=7; //Sensor trasero Derecho
int val;
void setup() {
//Leds como salidas
pinMode(Led1,OUTPUT);
pinMode(Led2,OUTPUT);
pinMode(Led3,OUTPUT);
pinMode(Led4,OUTPUT);
pinMode(Led5,OUTPUT);
pinMode(Led6,OUTPUT);
//Sensores como entrada
pinMode(shk1,INPUT);
pinMode(shk2,INPUT);
pinMode(shk3,INPUT);
pinMode(shk4,INPUT);
pinMode(shk5,INPUT);
pinMode(shk6,INPUT);
}
void loop() {
digitalWrite(Led1,LOW);
digitalWrite(Led2,LOW);
digitalWrite(Led3,LOW);
digitalWrite(Led4,LOW);
digitalWrite(Led5,LOW);
digitalWrite(Led6,LOW);
digitalRead(shk1);
digitalRead(shk2);
digitalRead(shk3);
digitalRead(shk4);
digitalRead(shk5);
digitalRead(shk6);
val=digitalRead(shk1);
if(shk1==HIGH)
{
digitalWrite(Led1,HIGH);
}
else
{
digitalWrite(Led1,LOW);
}
} //Cierre loop