Hi
S
Is it possible to use this code on ATtiny85?
I'm getting compiling error
I think it is the PWM.h library that are not suitble for ATtiny85
#include <PWM.h>
int outputPin1 = 1;
int dutyCycleInput = 12; //1-65535 Pulse with 0-100%
int DbL = 10;
void setup()
{
InitTimersSafe();
}
void loop()
{
//reading of analog input and computing of frequency out
int sensorReading = analogRead(A1);
int freqInput = map(sensorReading, DbL,1023, 0, 8000);
freqInput = constrain(freqInput, 0, 8000);
//pwm output
SetPinFrequencySafe(outputPin1, freqInput );
pwmWrite(outputPin1, dutyCycleInput );
}
And where do we find that "PWM library"? Remember, there are tons and tons of libraries and we don't know them all 
Here is where I got the library from
https://code.google.com/archive/p/arduino-pwm-frequency-library/
This is the error code I got when compliling
Arduino: 1.9.0-beta (Windows 7), Board: "ATtiny25/45/85, ATtiny85, Internal 16 MHz"
C:\Users\PSATHA~1\AppData\Local\Temp\ccXH6Rnd.ltrans0.ltrans.o: In function `setup':
C:\Users\psathammer\Desktop\ATTiny_85_PWM_output/ATTiny_85_PWM_output.ino:10: undefined reference to `InitTimersSafe()'
C:\Users\PSATHA~1\AppData\Local\Temp\ccXH6Rnd.ltrans0.ltrans.o: In function `loop':
C:\Users\psathammer\Desktop\ATTiny_85_PWM_output/ATTiny_85_PWM_output.ino:20: undefined reference to `SetPinFrequencySafe(signed char, unsigned long)'
C:\Users\psathammer\Desktop\ATTiny_85_PWM_output/ATTiny_85_PWM_output.ino:21: undefined reference to `pwmWrite(unsigned char, unsigned char)'
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board ATtiny25/45/85.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I found this.
Anyone that could help me to set a duty cycle of 5% and make it from 0 to 8000hz?
long analogvalue;
void setup() {
TCCR0B = 0;
TCCR0B = (1<<CS01); // /8 Prescaling
TCCR0A = 0;
TCCR0A = (1<<COM0B0) | (1<<WGM01); // toggle OC0B on compare match, CTC Mode 2
pinMode (1, OUTPUT); // PDIP Pin 6 // OC0B - Timer 0 "B"
pinMode (A1, INPUT);
} // end of setup
void loop() {
analogvalue = analogRead(A1);
analogvalue = map(analogvalue, 0, 1023, 61, 124); //map pot to 500Hz to 1000Hz
OCR0A = analogvalue;
}
I have use <PWM.h> on Arduino UNO two years ago and it worked on a Zoetrope project, but the initial values in the start of the program where like those:
#include <PWM.h>
int32_t frequency = 30; // Define the initial frequency
int8_t LEDpin = 3; // Defining LED pin
int LEDout = 170 ; // LED PWM output Value 0<--->255
and you can update the frequency Values and PWM like this:
frequency = constrain(frequency, 0, 10000);
LEDout = constrain(LEDout, 0, 255);
I will try to test the program on ATtiny44, and I hope it works.