Multithreading?? in Arduino


I just built a board with a bluetooth that uses a serial profile.I am continuously transmitting data through the bluetooth to the PC but need to toggle an LED every 8 seconds in parallel.I tried doing this but due to the delay I introduced for the LED toggling in my program my bluetooth also transmits data every 8 seconds now.

I tried using interrupts(internal and external) and also tried calling a blink LED function through setup() but have not been able to solve the problem.

Can anyone suggest any solutions or tell me where I may be going wrong.

Thanks so much!

Can anyone suggest any solutions or tell me where I may be going wrong.

Suggestions: Post your code.

Where you may be going wrong: You didn't post your code.

Generally you do not need multithreading for 8second precision.

See this library: It uses a concept called 'protothreading', as the 'blink without delay' sketch.

Thank you so much for sharing the TimeAction library.It worked!!!

I have another question though..with the TimeAction library I am able to turn my LED on for 8 seconds and OFF for 8 seconds.How can I have different times for the LED on time and off time e.g ON for 1 second and OFF for 8 seconds using ActionTime?

I tried the different permutation and combinations of functions given in the TimeAction library but I don't exactly know how to use them so not getting the correct result.

Thanks so so much!!

Once again posting your code would help. Just hit the # button in the message window and copy and paste your code between the 2 tags it gives.

Did you try the setInterval function?