Skip to content

Instantly share code, notes, and snippets.

Created March 20, 2017 18:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
* ATTINY85-LED-Boost.c
* Full article at
#include <avr/io.h>
#define F_CPU 1000000 // 1MHz, default for 8MHz internal osc and clkdiv8
#include <util/delay.h>
int main(void)
DDRB |= _BV(0); // Pin 5 = Output
while (1) // Blink forever at about 5Hz (100ms oscillating, 100ms off)
// This top section oscillates pin 5 at about for about 100ms
for(int i=0; i<10*100;i++ ) { // Each loop pass takes about 100us, so this for() will take ~100ms
// This is a 10KHz (50us high, 50us low) oscillator on pin 5
PORTB |= _BV(0);
PORTB &= ~_BV(0);
// This leaves pin 5 low for 100ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment