Skip action if the last data is the same

Hi!

So I keep reading data from serial, it can be "ON, "OFF" or "REBOOT", and this data is received continually.

Each reading takes different action, this is ok but I want ask something,

If I get "ON" over serial, I turn something ON,in the next loop if I read ON again I must skip the "ON" action until I get data different than "ON" over serial.

Can someone help me please?

Declare a global variable and Take a look at the Signal Edge detection example under the digital category, same principle of storing the last state.

So I keep reading data from serial, it can be "ON, "OFF" or "REBOOT", and this data is received continually.

Or change the sender to only send when there is a change, if the sender is in your control.

Thanks for the advice

I keep reading my tweet feed, and I can reboot, turn ON or OFF a computer remotely, but as I keep reading twitter every 60 seconds, if I get the same tweet it's going to perform the action everytime.