Timer Triggering

How to trigger this generator at 1V by potentiometer, wiper connected to PA6 ?

HardwareTimer pwmtimer(3);

void setup() {
 pinMode(PA7, PWM);
  pinMode(PA6, PWM);
  pwmtimer.pause();
  pwmtimer.setPrescaleFactor(1);       // Timer input clock Prescaler = 1 (= 72MHz input ?)
  pwmtimer.setOverflow(10000-1);            // PWM Period width for 7200 Hz ?
  pwmtimer.setCompare(TIMER_CH1, 5000);  // PWM High Pulse width is 50% duty (1:1)
  pwmtimer.refresh();
  pwmtimer.resume();
}

void loop() {
}

potValue = analogRead(potPin);
int potPin = PA7; // select the input pin for the potentiometer
int potValue = 0; // variable to store the value coming from the potentiometer

Please help me to remove the errors

//int analogPin = PA7;     // potentiometer wiper (middle terminal) connected to analog pin 3
int potPin = PA7;        // outside leads to ground and +5V
int val = 0;           // variable to store the value read


HardwareTimer pwmtimer(3);

void setup() {
  pinMode(PA7, INPUT_ANALOG);
  pinMode(PA6, PWM);
  pwmtimer.pause();
  pwmtimer.setPrescaleFactor(1);       // Timer input clock Prescaler = 1 (= 72MHz input ?)
  pwmtimer.setOverflow(10000 - 1);          // PWM Period width for 7200 Hz ?
  pwmtimer.setCompare(TIMER_CH1, 5000);  // PWM High Pulse width is 50% duty (1:1)
  pwmtimer.refresh();
  pwmtimer.resume();
}

void loop() {
  val = analogRead(potPin);     // read the input pin

  // read the value from the potentiometer
  potValue = analogRead(potPin);
  // turn the timer on
  digitalWrite(start, pwmtimer(3));
  // stop the program for <potValue> milliseconds:
  delay(potValue);
  // turn the ledPin off:
  digitalWrite(stop, pwmtimer(3));



  Serial.println(val);             // debug value
  ///////////////////////////////////////////////////////




}

The errors
C:\Users\OWNER\Documents\Arduino\trigger\trigger.ino: In function ‘void loop()’:

trigger:25: error: ‘potValue’ was not declared in this scope

potValue = analogRead(potPin);

^

trigger:27: error: ‘start’ was not declared in this scope

digitalWrite(start, pwmtimer(3));

^

trigger:27: error: no match for call to ‘(HardwareTimer) (int)’

digitalWrite(start, pwmtimer(3));

^

trigger:31: error: ‘stop’ was not declared in this scope

digitalWrite(stop, pwmtimer(3));

^

trigger:31: error: no match for call to ‘(HardwareTimer) (int)’

digitalWrite(stop, pwmtimer(3));

^

exit status 1
‘potValue’ was not declared in this scope

The error report does not lie.

For instance

C:\Users\OWNER\Documents\Arduino\trigger\trigger.ino: In function 'void loop()':

trigger:25: error: 'potValue' was not declared in this scope

   potValue = analogRead(potPin);

Where is potValue declared in the program ?

I'm guessing nowhere, that's why I gave the errors report and ask for help to fix it.

 val = analogRead(potPin);     // read the input pin

  // read the value from the potentiometer
  potValue = analogRead(potPin);

Did you really want to read potPin twice, once into a variable you have defined and then again into a variable you haven't?

And then you do a few digitalWrite()s to pins you also haven't defined.

The error messages really seem quite clear.

Steve

post #1 second line - it is not a declaring ?

The report is clear, but is it for me not clear what to do.

ted:
post #1 second line - it is not a declaring ?

Yes. It declares a variable called val. You're trying to use a variable called potValue. val and potValue are not the same.

Steve

a new code less errors.

//int analogPin = PA7;     // potentiometer wiper (middle terminal) connected to analog pin 3
int potPin = PA7;        // outside leads to ground and +5V
int val = 0;           // variable to store the value read
int.potValue;
int.pwmpin=PA6;
HardwareTimer pwmtimer(3);

void setup() {
  pinMode(PA7, INPUT_ANALOG);
  pinMode(PA6, PWM);
  pwmtimer.pause();
  pwmtimer.setPrescaleFactor(1);       // Timer input clock Prescaler = 1 (= 72MHz input ?)
  pwmtimer.setOverflow(10000 - 1);          // PWM Period width for 7200 Hz ?
  pwmtimer.setCompare(TIMER_CH1, 5000);  // PWM High Pulse width is 50% duty (1:1)
  pwmtimer.refresh();
  pwmtimer.resume();
}

void loop() {
  val = analogRead(potPin);     // read the input pin

  // read the value from the potentiometer
 // potValue = analogRead(potPin);
  // turn the timer on
 // digitalWrite(start, pwmtimer(3));
  // stop the program for <potValue> milliseconds:
 //delay(potValue);
  // turn the ledPin off:
 // digitalWrite(stop, pwmtimer(3));



  Serial.println(val);             // debug value
  ///////////////////////////////////////////////////////




}

rigger:6: error: expected unqualified-id before '.' token

int.potValue;

^

trigger:7: error: expected unqualified-id before '.' token

int.pwmpin=PA6;

^

exit status 1
expected unqualified-id before '.' token

What gave you the idea that you could substitute a period for a space?

  // read the value from the potentiometer
 // potValue = analogRead(potPin);
  // turn the timer on
 // digitalWrite(start, pwmtimer(3));
  // stop the program for <potValue> milliseconds:
 //delay(potValue);
  // turn the ledPin off:
 // digitalWrite(stop, pwmtimer(3));

Well yes, if you comment out most of the code you will get less errors. Congratulations.

Steve

Thanks guys, I am slowly moving forward

//int analogPin = PA7;     // potentiometer wiper (middle terminal) connected to analog pin 3
int potPin = PA7;        // outside leads to ground and +5V
int val = 0;           // variable to store the value read
int potValue;
int pwmpin = PA6;
int startpwmtimer(3);
int stoptpwmtimer(3);
int start;
int stop ;

HardwareTimer pwmtimer(3);

void setup() {
  pinMode(PA7, INPUT_ANALOG);
  pinMode(PA6, PWM);
  pwmtimer.pause();
  pwmtimer.setPrescaleFactor(1);       // Timer input clock Prescaler = 1 (= 72MHz input ?)
  pwmtimer.setOverflow(10000 - 1);          // PWM Period width for 7200 Hz ?
  pwmtimer.setCompare(TIMER_CH1, 5000);  // PWM High Pulse width is 50% duty (1:1)
  pwmtimer.refresh();
  pwmtimer.resume();
}

void loop() {
  val = analogRead(potPin);     // read the input pin

  // read the value from the potentiometer
  potValue = analogRead(potPin);
  // turn the timer on
  //  digitalWrite(start, pwmtimer(3));
  // stop the program for <potValue> milliseconds:
  //delay(potValue);
  // turn the ledPin off:
  digitalWrite(stop, pwmtimer(3));



  Serial.println(val);             // debug value
  ///////////////////////////////////////////////////////




}

the errors
C:\Users\OWNER\Documents\Arduino\trigger\trigger.ino: In function 'void loop()':

trigger:36: error: no match for call to '(HardwareTimer) (int)'

digitalWrite(stop, pwmtimer(3));

^

exit status 1
no match for call to '(HardwareTimer) (int)'

// turn the ledPin off:
  digitalWrite(stop, pwmtimer(3));

Read the comment, then try to decide if the comment matches what the code is supposed to do.
The compiler is telling you that it doesn't know what to do with pwmtimer in the context of what it is expecting, which is an int, typically which would represent HIGH or LOW.

But I want to replace HIGH and LOW by START and STOP, before posting anything I am trying all options which come to me, reading errors.

ted:
But I want to replace HIGH and LOW by START and STOP, before posting anything I am trying all options which come to me, reading errors.

That's fine - just make sure that START and STOP have int representations that match HIGH and LOW (or vice versa)

no match for call to '(HardwareTimer) (int)'

I can't figure out what that is mean

It means that the compiler cannot make an int out of "(HardwareTimer) (int)" to pass to digitalWrite.