I am having a strange problem with arduino Leonardo.
I wrote a sketch with atachinterrupts, just for try as i am new to this.
After upload to arduino the computer lost comunication with the leonardo and any time i connect usb port it says it doesn t recognize Hardware.
I am almost sure that the problem is the sketch i wrote since i have two boards, and i tried to upload the same program to the other and it began to do the same.
I hope i didn t damaged the boards, i don t have a clue what is hapenning.
The sketch is:
volatile int state = LOW;
//unsigned long time;
void setup ()
pinMode (pin, OUTPUT);
attachInterrupt (0, parvoice, LOW);
void parvoice ()
Any help is welcome.
Add some more information:
I have windows 7;
Both boards where working normally;
The message i get when try to upload is:
avrdude: usbdev_open(): did not find any USB device "usb";
I have not instaled or uninstaled nothing in the computer.
It was the sketch, i connected pin 3 to 5 volt and could be able to upload anoyher sketch.
Lesson learned, very careful with atachinterrupt
But now i have another doubt:
I declared interrupt 0 on the sketch and in hardware details of leonardo this interrupt correspond to pin 2, i tried first with pin 2 connected to 5 volt and the problem persisted.
So am i missing something or interrupt pins are diferent in leonardo then in other boards?
Thanks a lot.
An interrupt service routine should be fast.
void parvoice ()
By what stretch of the imagination can delay() be considered fast?
delay() does not work inside an ISR, for good reasons. DO NOT DALLY in an ISR. For any reason. Get in; do something; get out.