Pulse in is too slow for ATTiny85 - help?

I’ve been researching a solution for this all day. I’m trying to use the gear switch on my RC transmitter to switch the pattern on my LEDs and then revert back to another pattern when off.

My research brought me to two solutions PulseIn() and to use interrupts (whatever they are :slight_smile:

I can successfully write a sketch on my uno that outputs a string “on” or “off” to the serial monitor based on the value of the input pin (ie <1500) and all works well.

I can successfully run a sketch on my attiny85 that cycles through RGB led patterns using a push button switch. But when i try to merge the two the PulseIn() block of code really bogs down everything. The LEDs run through one cycle and pause then continue.

I found this post: http://digistump.com/board/index.php?topic=689.0

but i dont know how to implement anything he is talking about (plus its in French).

All I want to do is monitor whether a transmitter switch is on or off. Maybe in the future use a transmitter pot to set the pattern, based on its position (or something)

Can anyone help me?

Thank you in advance for your time.

But when i try to merge the two the PulseIn() block of code really bogs down everything.

Post this code, we aren’t mind readers.

How to use this forum

… to use interrupts (whatever they are)

Interrupts

Pulsein WAITS until a pulse arrives. While your arduino is dong that it's doing nothing else. WAITING is very unproductive.

Here's a rough idea

bool lastState=0;
void loop()
{
bool testState=digitalRead(pulsePin);
  if(testState>lastState)
    {//Do something here because the rising edge has arrived  

    }
//update Global variable ready for the next pass of the loop
lastState=testState;
}