Posts

Showing posts from May, 2020

ATTINY25/45/85 Low Power Led Flasher

Connect Led to PIN PB0 0f Tiny25/45/85 (Pin No.5) Code: //ATTINY25/45/85 #include <avr/sleep.h> #include <avr/wdt.h> #ifndef cbi #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #endif #ifndef sbi #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #endif int pinLed = 0; volatile boolean f_wdt = 1; void setup() {   pinMode(pinLed, OUTPUT);   // 0=16ms, 1=32ms,2=64ms,3=128ms,4=250ms,5=500ms   // 6=1 sec,7=2 sec, 8=4 sec, 9= 8sec   setup_watchdog(9);    // approximately 8 seconds sleep } void loop() {   if (f_wdt == 1) { // wait for timed out watchdog / flag is set when a watchdog timeout occurs     f_wdt = 0;     // reset flag     digitalWrite(pinLed, HIGH); // let led blink     delay(70);                  //On Time     digitalWrite(pinLed, LOW);     pinMode(pinLed, INPUT); // set all used p...

ATTINY13 Low Power Led Flasher

Connect led to pin PB0 of Attiny13 (Pin No.5) Code: //ATTINY13A #define F_CPU 1200000UL       // MCU frequency in hertz #include <avr/io.h> #include <avr/wdt.h>        #include <avr/sleep.h>      #include <avr/power.h> #include <avr/interrupt.h>  #include <util/delay.h> #define led 0                 // PB0 int main( void )              // similar to void setup () {   wdt_reset();                // first you need to reset the Wachdog   // otherwise there may be a reboot   pinMode(led, OUTPUT);   while (1) {                 // perpetual loop, analog of void loop ()     digitalWrite(led, HIGH);     _delay_ms(50);            // On Time ...