Dear hannibalal,
I really appreciate that you posted your code as I have a 2022 that I am currently trying to interface so that I can build a custom servo system.
I've have studied the datasheet in depth and implemented your code and wiring, but I just get 0's
And ideas on what might have gone wrong?
I can post my wiring diagram once I have a chance to draw a schematic.
I am using an extra Nano board with some code I copied to try and generate a clock pulse, maybe this is the problem?
Can anyone help me get my pulses counted? I really need this to work for a prototype of a sustainable transport invention I am building...
I am using an Arduino Nano to try and act as an external clock signal, (the rest is hooked up to a Mega)
My main code is identical to hannibalal and I am using this for clock signal:
//Use Timer/Counter1 to generate a 1MHz square wave on Arduino pin 9.
//J.Christensen 27Apr2012
//**********from https://forum.arduino.cc/index.php?topic=103370.0
void setup(void)
{
DDRB = _BV(DDB1); //set OC1A/PB1 as output (Arduino pin D9, DIP pin 15)
TCCR1A = _BV(COM1A0); //toggle OC1A on compare match
OCR1A = 7; //top value for counter
TCCR1B = _BV(WGM12) | _BV(CS10); //CTC mode, prescaler clock/1
}
void loop(void)
{
}
