I am trying to use an Attiny45 as an Arduino such as here http://www.forkrobotics.com/2012/04/run-arduino-code-on-an-attiny/ using the Arduino-tiny cores. Now according to the diagram on the site pin D0, D1, D3 and D4 should have 8bit PWM capabilities but while testing with an LED only D4 works correctly, D3 goes completely on or completely off and D0 and D1 flicker while not completely on or off. I know the tutorial is for the Attiny85 but as far as I can determine the only differnce between it and the 45 should be RAM and flash storage. Also the 8bit is derived from the retailers website which states that there should in fact be 6 8-bit PWM channels https://za.rs-online.com/web/p/microcontrollers/6962614 Do any of you have any idea what could be causing this?
The code is just a version of Blink modified to switch between 100% and 50% duty cycle rather than on or off:
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 3;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
//digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
analogWrite(led, 255);
delay(1000); // wait for a second
//digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
analogWrite(led, 127);
delay(1000); // wait for a second
}