I have recently made a pwm dimmer with the standard 328pu chip and put it in a circuit of its own to dimm and LED as a test using a pot etc.
This has been working fine using this code.
int potPin = 0; // Analog in 0 connected to the potentiometer
int transistorPin = 9; // connected to the base of the transistor
int potValue = 0; // value returned from the potentiometer
void setup() {
// set the transistor pin as output:
pinMode(transistorPin, OUTPUT);
}
void loop() {
// read the potentiometer, convert it to 0 - 255:
potValue = analogRead(potPin) / 4;
// use that to control the transistor:
analogWrite(9, potValue);
so thats just using the analogwrite standard pwm output of 450hz or whatever it is.
so i now want to shrink my dimmer on to an attiny45 which i have. i also have an arduino as isp shield
that i bought off ebay to programme my attiny45.
programmed the arduino for the isp programmer, sat my attiny45 chip in the holder of the shield and
programmed it.
i seem to be getting no PWM output, am i missing something? i assigned my code to the pin out of the attiny45
from that website using internal 8mhz clock on the attiny45. The varying voltage from the pot is going to the an analog
in pin but no PWM to drive the mosfet IRL540N. I previously used this in the arduino project so the attiny should still have enough
charge current to drive the gate of the mosfet.
pot to pin 2 (pin 7 on attiny45) and pwm out pin 0 (pin 5 on attiny45)
And got no output pwm so far.
-----------------------------------PWM CODE ARRANGED FOR ATTINY45 PIN OUT---------------------------------------
int potPin = 2; // Analog in 0 connected to the potentiometer
int transistorPin = 1; // connected to the base of the transistor
int potValue = 0; // value returned from the potentiometer
void setup() {
// set the transistor pin as output:
pinMode(transistorPin, OUTPUT);
}
void loop() {
// read the potentiometer, convert it to 0 - 255:
potValue = analogRead(potPin) / 4;
// use that to control the transistor:
analogWrite(1, potValue);
}
cheers for the heads up. i just updated the code and i am getting this error when programming. I know the BS2 lines are ok but
not too sure what all this other stuff is underneath.
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny45
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny45
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): programmer is out of sync
I read somewhere the arduino as ISP code is basically naff! in version 1.0 or 1.0.1.
so you have to go back to previous software, i used arduino 0022 software. Programmed the standard arduino 328 chip
as the programmer using arduino as isp code, then switched back to 1.0.1 software to program the attiny in my isp shield
using the attiny45_85 zip file which contains the code/pinouts for the arduino/hardware folder.
then burn attiny bootloader depending on which freq you want to use (eg. 1 or 8mhz internal or 20mhz external clock)
then program to the right pin out.
light dimmer is working on attiny45.
since i am using an internal clock of 8mhz for the dimmer. would there be any advantage adding the extra components for xtal
external 20mhz clock? or wouldnt it matter?
well it worked untill i wanted to re program it so now it wont burn bootloader or upload code to attiny45
avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny45
avrdude: Yikes! Invalid device signature.
Double check connections and try again, or use -F to override
this check.
all i am getting it that message above. it was working but i am not sure how you are suppose to
keep re programming the attiny45 over and over with no errors
this is on upload, trying to re load the bootloader at 8mhz on the attiny45. i had it working before i just dont understand
why its not burning so i can re programme the chip again.
i am using this shield i got off ebay so i minimised any wiring problems, so its just the attiny in the 8 pin socket and the 328 chip is sat underneath in the arduino for the isp programmer
I have been using the shield to program then dropped my attiny in my breadboarded PWM
Circuit. Which I got working recently. So I put the chip back in and burnt the 20mhz
Bootloader to the attiny trying to test if there was any difference in light dimming
Or duty cycle between 8 internal and 20 external
(just because this project used 20mhz
External) before I started to shrink the project down to attiny.
After I tried the 20mhz bootloader it's as if I bricked the chip. Doesn't want
To bootload or upload program.
I am wondering if I have dry joints on my R3 arduino as am sure I noticed something
Dodgy with the connections when I first got it. Bit not had anything wrong Since.
You can't use serial programming unless the system clock is working. Once you have programmed the fuses for an external crystal oscillator you have to connect the crystal (and load capacitors) or resonator to pins 2 and 3. I don't see a crystal for the ATtiny socket on your programming shield. That would explain why you can't program it.