ATtiny85 simple circuit 230809

Thread Starter

allenpitts

Joined Feb 26, 2011
161
Hello AAC forum,

Working with ATTiny85 to use input from motion detector
to turn on 12 volt LEDs.
Working with info found at
https://blog.hobbycomponents.com/?p=553
a circuit to test the tiny microcontroller was developed.
ATtiny_Simple_Blink_Schematic_230809.jpg
Using sketch copied herewith below.
The expected result is that the LED would blink on and
off at one second intervals.
The actual result is the LED comes on and stays on.
Thinking that perhaps I had programmed the wrong pin
in the sketch the lead to R1 was touched to the 3 pin
and the same result was achieved. That is, the LED comes on
and stays on. This result also came from touching the
resistor lea to pins 0, 1, and 2.
The circuit is so simple the only component that might be failing
is the MC itself so several different out-of-the-box ATtiny85s
have been tried.
What am I missing?
Thanks.
Allen Pitts

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

modified 8 May 2014
by Scott Fitzgerald
*/


// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 4 as an output.
pinMode(4, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
digitalWrite(4, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(4, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
 

Ya’akov

Joined Jan 27, 2019
8,568
Try specifying the pin as PB4 like this:

int LED = PB4; at the top of the program; then

pinMode(LED, OUTPUT); in setup().

Use physical pin 3, as your schematic shows, for the LED connection.
 

DickCappels

Joined Aug 21, 2008
10,104

Ya’akov

Joined Jan 27, 2019
8,568
Did you select the internal RC clock?

You should probably add the recommended reset circuit:
View attachment 300162
https://onlinedocs.microchip.com/pr...tml?GUID-B80B25FF-E9D7-4766-B562-DA197B8B938C

I would put a 10 uf aluminum electrolytic in parallel with a good quality ceramic .01 uf capacitor between VCC and Ground, in close proximity to the '85.

You should keep the datasheet at hand.
https://www.microchip.com/en-us/product/ATtiny85#document-table
In practice, I’ve found that the bypass cap and a the reset pull-up though not always needed, can prevent mysterious problems.

But, in the Arduino environment, depending on the board support he is using, he may need to use the constants (PB1PB0 .. PB5) to address the pins.
 

djsfantasi

Joined Apr 11, 2010
9,131
You set pin 4 to be for output and set it HIGH.
Pin 4 is ground. Setting it HIGH creates a short. You may have destroyed the chip.

The Arduino IDE maps standardized names to physical pins. This is so one can code for different processors without having to change the PIN numbers for each one. On the ATTiny85, “PB4” maps to actual pin 3. Which is what the schematic implies.
 

Thread Starter

allenpitts

Joined Feb 26, 2011
161
Hello Ya’akov, DickCappels, djsfantasi and the AAC forum,

Thanks for the replies.

Not having much luck.

Test 1
Based on post #2 from Ya’akov the sketch was changed as
shown in sketch marked 'Blink 230809 PB4' copied below.
Also at the Arduino IDE checked Tools > Internal clock 8 MHZ
Result no change.

Test 2
Not sure is the DigitaiWrite statement should be
digitalWrite(LED, HIGH);
or
digitalWrite(3, HIGH);
so substitured the latter as copied herewith
below marked 'Blink 230809 PB4_3'
Result no change.

Test 3
Based pn DickCappels' post #3
3.1 Changed sketch back to
digitalWrite(LED, HIGH);
3.2 Changed circuit to add
.1 uF cap between the reset
pin and ground as shown.
ATtiny_Simple_Blink_Schematic_230809_b.jpg
Result no change.

Test 4
Realized that DickCappels' post #3
also called for a 10 uF cap between
the voltage source and ground.
Refactored circuit thus:
ATtiny_Simple_Blink_Schematic_230809_c.jpg
Result no change.

Test 5
Based on djsfantasi's post # 5
checked that ATtiny85 data sheet
says that pin 3 is PB4 and
replaced MC with fresh unit.
Result no change.

The thing that is twisting my head around
is the circuit was begun based on
info found at
https://blog.hobbycomponents.com/?p=553
which includes this circuit.
Attiny_circuit_breadboard_230423.png
So either these guys are whacky
or this circuit needs to be more
complex than what is shown at
Hobby Components.

Thanks.

Allen Pitts

***********Blink 230809 PB4 ******************

/*
Blink 230809 PB4
Turns on an LED on for one second, then off for one second, repeatedly.
modified 8 May 2014
by Scott Fitzgerald
*/
int LED = PB4;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 3 as an output.
pinMode(LED, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {

digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

***********end Blink 230809 PB4 ******************

***********Blink 230809 PB4_3******************

/*
Blink 230809 PB4_3
Turns on an LED on for one second, then off for one second, repeatedly.
modified 8 May 2014
by Scott Fitzgerald
*/
int LED = PB4;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 3 as an output.
pinMode(LED, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {

digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

***********end Blink 230809 PB4_3******************
 

sagor

Joined Mar 10, 2019
866
Shouldn't Reset (pin 1) be held high? When low, it resets the chip. Not sure what happens when you hold it low indefinitely.
 

djsfantasi

Joined Apr 11, 2010
9,131
Hello Ya’akov, DickCappels, djsfantasi and the AAC forum,

Thanks for the replies.

Not having much luck.

Test 1
Based on post #2 from Ya’akov the sketch was changed as
shown in sketch marked 'Blink 230809 PB4' copied below.
Also at the Arduino IDE checked Tools > Internal clock 8 MHZ
Result no change.

Test 2
Not sure is the DigitaiWrite statement should be
digitalWrite(LED, HIGH);
or
digitalWrite(3, HIGH);
so substitured the latter as copied herewith
below marked 'Blink 230809 PB4_3'
Result no change.

Test 3
Based pn DickCappels' post #3
3.1 Changed sketch back to
digitalWrite(LED, HIGH);
3.2 Changed circuit to add
.1 uF cap between the reset
pin and ground as shown.
View attachment 300179
Result no change.

Test 4
Realized that DickCappels' post #3
also called for a 10 uF cap between
the voltage source and ground.
Refactored circuit thus:
View attachment 300180
Result no change.

Test 5
Based on djsfantasi's post # 5
checked that ATtiny85 data sheet
says that pin 3 is PB4 and
replaced MC with fresh unit.
Result no change.

The thing that is twisting my head around
is the circuit was begun based on
info found at
https://blog.hobbycomponents.com/?p=553
which includes this circuit.
View attachment 300181
So either these guys are whacky
or this circuit needs to be more
complex than what is shown at
Hobby Components.

Thanks.

Allen Pitts

***********Blink 230809 PB4 ******************

/*
Blink 230809 PB4
Turns on an LED on for one second, then off for one second, repeatedly.
modified 8 May 2014
by Scott Fitzgerald
*/
int LED = PB4;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 3 as an output.
pinMode(LED, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {

digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

***********end Blink 230809 PB4 ******************

***********Blink 230809 PB4_3******************

/*
Blink 230809 PB4_3
Turns on an LED on for one second, then off for one second, repeatedly.
modified 8 May 2014
by Scott Fitzgerald
*/
int LED = PB4;
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 3 as an output.
pinMode(LED, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {

digitalWrite(3, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(3, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

***********end Blink 230809 PB4_3******************
That breadboard pic is wacky. Your schematic should work. But in the circuit on the breadboard, both LED leads are shorted and connect nowhere.
 

sagor

Joined Mar 10, 2019
866
There is an internal pull-up on the reset pin. On most controllers this is in the vicinity of 50 k Ohms.
But in test #4, he shows it tied to ground. Of course that test would not work. To be sure, I’d put a 10k pull-up on that pin to Vcc, but that is me…
But then, I don’t know what his programming bits (fuses) are, maybe he disables RESET.
 
Last edited:

MrChips

Joined Oct 2, 2009
29,868
Just to make it clear, ATtiny85 and Arduino are two different things.

ATtiny85 is the MCU chip made by Atmel, now owned by Microchip.
You can program ATtiny85 in C language directly using the right tools.

Arduino is an IDE (integrated development environment) platform that has been adapted to many different MCUs, including Atmel AVR chips such as ATtiny85 and ATmega328. A "sketch" is the user program that resembles C language. The MCU has to be preprogrammed with a bootloader before it can be programmed with the sketch. Atmel MCUs straight from the supplier does not have this bootloader installed.
 

DickCappels

Joined Aug 21, 2008
10,104
This (pin 1) is wrong. The RESET pin is held low to reset to controller. It should be high for normal use and at an even higher voltage during programming.

1691688367111.png

From the datasheet, notice the bar over the word RESET on pin 1. This indicates that the pin is active when it is low.

1691688964602.png
Below is also from a Microchip application note. This is the way I have been connecting my AVR controllers for over 20 years.
1691689205605.png

Where I often ran into problems, and still do today is getting the chip programmed. I use and old integrated development environment and whatever programmers I can find that seem to be able to work.

A key question, is what steps are you using to compile your program and what hardware configuration are you using to program the chip. This should not be hard to "fix" but getting one thing wrong leaves us with a non-functioning chip.
 

Ya’akov

Joined Jan 27, 2019
8,568
2-3 years ago I did various work using the Arduino IDE with various ATTiny85 projects. I made comprehensive notes so that I would be able to recreate / understand what I did if I needed to revisit the work in the future.
Some of these notes may be of help to you.
Excellent as usual, @Dave Lowther. A couple of comments:

The board support URL is out of date, the current version, for the most popular ATTiny* support, the new URL is http://drazzy.com/package_drazzy.com_index.json which will install the latest version of ATTiny Core.

As far as programmers go, I have used several methods but one of the nicest (though not the cheapest) can be found here. Though it appears the maker is on a hiatus. Most most recommended ATTiny 8-pin programmer is the Sparkfun Tiny AVR, though clones are available for a much lower price (it‘s open source).

As always I say if you can afford the extra bucks to help (Sparkfun, AdaFruit, et al) keep that open source hardware goodness coming, it’s definitely a good investment but if not, the clone is cheap.
 
Top