Baby-Orangutan interrupts


Im new here and I.m kinda stuck with a problem… i read that for using interrupts with baby-O i can use some pulse functions but i cant make it work…

My project:
a robot that uses 2 ir sensors and needs to follow an object. I want to use interrupts like -> when i see the object with rightSensor turn to right, same for left and when i see with both to go forward.

I tried to use some interrupts but both my sensors are on PCINT0_vect and i can.t say wich is wich. And also it moves when i get the signal but it wont move till it gets a new signal … even if the object is still infront of me.

I saw i can use something with pulse but i dont rlly know how to use them efficient can anyone give me a lil advice pls ?

You need to keep a copy of the most recent port input values in memory. During an interrupt on change, read the port and compare to the memory copy. That will indicate which input caused the interrupt.

You probably do not need to use interrupts. Just poll the port during the main loop and look for changes.

After i run the code in interrupt function can i go to a certain point in code(like beginning of main or something) instead of continuing form the point where the interrupt occurred ?

In general, no. It is possible for an interrupt to reboot the MCU, though.


I am sorry you are having problems implementing interrupts on your Baby Orangutan. As Jim mentioned, polling the port during the main loop would probably work fine, and you might be able to avoid using interrupts. However, if you want to use interrupts, you might consider raising a flag during the ISR and having your main loop check the flag to command the robot to turn appropriately.

If you post your code, I would be happy to take a look at it and give pointers. Along with your code, could you tell us more about the sensor you are using and how you have everything connected? Pictures and diagrams would be very helpful.

- Jeremy