I am a new user of arduino.i would like to make a simple programme to blink the LED by using the fonction interruption (attachInterrupt). Can someone help me??``

The attachInterrupt function is used to define a function to execute when an EXTERNAL event occurs. What EXTERNAL event is going to trigger your LED to turn on or off?

for example.Can we make likes when we give a signal for the interruption(by push button), it will on the led and also trigger the timer for likes 30s and after that it will turn of the led???

for example.Can we make likes when we give a signal for the interruption(by push button), it will on the led and also trigger the timer for likes 30s and after that it will turn of the led???

You could, if the switch is wired correctly.

But, why? If the only thing the Arduino is doing is reading the switch state and turning an LED on or off at the right time, polling is going to be more than fast enough.

Interrupts add a whole level of complexity that should be avoided until you have to use them.

is there any example cade for make the programme like this??
im really a new user for arduino and also for the programming…
it means that by using the polling will make the things more easier??
But i’d been asking to use the interrupt for realise this programme…

But i'd been asking to use the interrupt for realise this programme

So, you're asking for help with your homework?

not likes that..i would likes to learn how we can make a code..honestly im in a process to learn the sorry if u thought im using this forums for my own advantages..

Seriously, if you're a beginner the use of interrupts is so full of pitfalls that it just isn't worth doing until you've got some grounding on basic programming, and the speed at which microcontrollers operate.

the choses that i really do not understands is whats the difference between polling and interruptions??? for me its looks liked theres no big differences

Polling means writing your code so that it explicitly looks at a certain input when you want it to, at the rate you want.

Interrupts mean that the processor automatically looks at the input every single instruction cycle, i.e. 16 million times a second. When the processor detects the interrupt condition, it calls the interrupt service routine immediately. You have NO control over when this happens, and badly written interrupt code can cause all sorts of unexpected side-effects.

On the other hand, badly written polling code can miss an event.

If you need to read a button or detect some other transient event, polling will work. But, your code is probably doing a bunch of other stuff at the same time. So, you need to make sure you don't do things like have long delay calls, or loop around just waiting for input from the serial port and so on.

You're going to end up with a state machine. A state machine is code that loops around and does a little bit of work in each pass, then sets a flag so it will know what the next step is. Then you can do a little work, check your button, do a little work, check the button, do a little work . . .

If you get bogged down doing all your work, you can miss the button press. An interrupt helps prevent missing an event while your code is off doing something else. But, there are times when your code can not be interrupted, like reading data or something like that. You you need to turn interrupts off during this time. This is called putting them down. You have to remember to turn them back on. Also, if your interrupt handler operates on data that the looping code also operates on, you need to be sure that data is in a valid state.

Functions called by an interrupt are called "interrupt service routines" or ISR. They need to be very short. A good way to use them is to have them set a flag for the polling code to check. this way, your flag is set when he button is pressed. You don't miss the button press, but you also don't spend a lot of time in the ISR doing whatever the button causes to happen.

The best use of an ISR is when something HAS to be done right away. If you have a stream of data coming in at high speed, each byte triggers an interrupt, which takes the data and stores it in a buffer. This way you don't miss the next byte that is coming in. Things like that are the most appropriate use of an ISR.

Start with the looping code and skip the interrupts for now. Once you get that working, then get fancy.

/*volatile int etat=LOW;

void setup() { pinMode (13,OUTPUT); attachInterrupt (0,bISR,CHANGE); // interrupts(); }

void loop() { digitalWrite (13,etat); }

void bISR() { etat=!etat; }*/

this is the example code i found in the this the example by using the interruption or polling???

It is an example of both; "loop" polls the variable "state" (etat), but the variable is set by interrupt. Don't be fooled by the simplicity of the example - a real-world aplication could be much more complex. (e.g. debounce)

ok and thank you for ur advice and help...i really love to learn the programmation..i'll look up from the basic...and i'll try make the code for my problem... thanks everyone