0

We used the analogwrite function to create a PWM signal on the arduino nano every. However that has a fixed frequency of around 500 Hz and we were looking for one above 250000 HZ, hence I came across this blog post:https://forum.arduino.cc/t/varying-the-pwm-frequency-for-timer-0-or-timer-2/16679#msg121031 . I tired changing it accordingly but keep getting an error

type hconst int pwmPin = 3;
void setup() {
  Serial.begin(115200);
   
  Serial.println("ready");
  TCCR2A  = TCCR2B & 0b11111000 | <0x01>;


}

void loop() {
   
  int data = Serial.read();

  if (data == 1) {
    
    pinMode(pwmPin, OUTPUT);  
    analogWrite(pwmPin, 204);
    Serial.println('A');

  }
  else if (data == 0) {
    
    pinMode(pwmPin, OUTPUT); 
    analogWrite(pwmPin, 76.5);
    delay(3000);
    analogWrite(pwmPin, 0);
    Serial.println('b');
  }
  


}

// settings file
// Controler functions in a while
// classs in c# for each of the ones above 
//ere

We keep getting an error in that TCCR2A is not detected, I was hoping someone could help us set the timer differently, so that we could generate a frequency PWM Arduino signal

This is the specific error: "Compilation error: 'TCCR2A' was not declared in this scope"

0 Answers0