sketch works fine on Uno but get compiling error for Micro???

#include <avr/interrupt.h>
#include <avr/io.h>
#include <SoftwareSerial.h>
// Create a software serial port! ON PIN 9
SoftwareSerial lcd = SoftwareSerial(0,9);

#define INIT_TIMER_COUNT 6
#define RESET_TIMER2 TCNT2 =INIT_TIMER_COUNT //****error here

//****compilier errors out here stating TCNT2 has not been defined??

But no problem for Uno…I thought sketches would run across all arduinos???

Any ideas??

Thanks

Eric

The line in question directly accesses a hardware register. The error indicates the processor on the Micro does not have that hardware.

what should I use instead? Any suggestions??

Eric

An Uno. Or fix the code.

I'm looking for a solution to fix the code for a micro but I'm a bit stuck...Any ideas?

Thanks in advance

Eric

You are asking for a solution that only you can provide. The reason is that only you have the source code. And, only you know what the code is supposed to do. And, only you know what the code is actually doing.

Use code tags.

I have a cog geartooth sensor that at each state change will reset an counter…timer2 will increases a counter every 50ms…if that counter gets to 4 then a relay is triggered…Again the geartooth sensor resets the counter each state change…I found some example code and inserted it in my sketch…works great on Uno and as you suggest I need to fix the code…I am weak on the interrupt timer and realize the Micro doesn’t have timer 2…Anybody out there to help with a correction on the timer for the micro?? Id like to use the smaller form of the micro instead of the Uno but this is my hurdle!!

Thanks

Eric

Relevant code below

#include <avr/interrupt.h>
     #include <avr/io.h>
     #include <SoftwareSerial.h>
     // Create a software serial port! ON PIN

Use a Nano. Same processor as Uno but much smaller form factor.

Thanks best advice so far THANKS!!!