Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years ago.
Can't turn on the LED
Hello,
I have 5 switch and I use the intrruptIn for each switch to turn on the LED on the board but when I use more the 3 IntrruptIn the led turn on only with 3 switch and the others no.
Can anyone tell me why I can't turn on the LED when I use more than 3 interruptIn ?
Thank You
1 Answer
8 years ago.
STM devices can only use one InterruptIn per pin number, so if you have an InterruptIn on PA_0, you can also have one at PA_2, and PA_3, and PB_2, PD_5, etc, but you cannot have an InterruptIn on PB_0, or PC_0, etc. See the pinout for which actual ports/pins you are using. For the A0-A5's (which are Arduino names and not their actual name):
Hi Faris,
Can you post your code here? :)
Regards,
Andrea, team mbed
posted by Andrea Corrado 15 Nov 2016Hi andrea
here is my code,
DigitalOut led(LED1);
InterruptIn laser1(A0); InterruptIn laser2(A1); InterruptIn laser3(A2); InterruptIn laser4(A3); InterruptIn laser5(A4);
char C=67; char B=66; char A=65;
int LASER1; int LASER2; int LASER3; int LASER4; int LASER5;
void allume_verrine() { LASER3 = laser1.read(); LASER3 = laser2.read(); LASER3 = laser3.read(); LASER4 = laser4.read(); LASER5 = laser5.read();
if (LASER1 == 1 || LASER2 == 1|| LASER3 == 1 || LASER4 == 1 || LASER5 == 1 ) { rn42.putc(B); led= 1 ; } }
void eteint_verrine() { LASER1 = laser1.read(); LASER2 = laser2.read(); LASER3 = laser3.read(); LASER4 = laser4.read(); LASER5 = laser5.read();
if ( LASER1 == 0 && LASER2 == 0 && LASER3 == 0 && LASER4 == 0 && LASER5 == 0) { rn42.putc(A); led= 0 ;
} }
int main() { rn42.baud(115200); led=0;
laser1.rise(&allume_verrine); laser2.rise(&allume_verrine); laser3.rise(&allume_verrine); laser4.rise(&allume_verrine); laser5.rise(&allume_verrine);
laser1.fall(&eteint_verrine); laser2.fall(&eteint_verrine); laser3.fall(&eteint_verrine); laser4.fall(&eteint_verrine); laser5.fall(&eteint_verrine);
while(1) {
} }
posted by Alexandre JAFFRE 15 Nov 2016Please post code using
posted by Andy A 15 Nov 2016<<code>>
tags, that way the formatting is preserved. e.g.