Hi, i'm trying to upload this sketch to an attiny85, and upon compiling, it tells me that this expression can not be used as a function:
WDTCR |= (1<<WDCE) | (1<<WDE);
Here's the full sketch:
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/interrupt.h>
const int switchPin = 1;
const int relayPin = 0;
unsigned int count = 1;
bool flag = 0;
bool intflag = 0;
void setup()
{
//avrdude -U lfuse:w:0x53:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m //disable many things
ADCSRA = 0;
WDT_off();
power_all_disable (); //this needs to be AFTER ADCSRA = 0;
pinMode(switchPin, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
digitalWrite(relayPin, flag);
}
void sleep()
{
GIMSK |= _BV(PCIE); // Enable Pin Change Interrupts
PCMSK |= _BV(PCINT1); // Use PB1 as interrupt pin
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // replaces above statement
sleep_enable(); // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
sei(); // Enable interrupts
MCUCR |= bit (BODS) | bit (BODSE); // turn on brown-out enable select
MCUCR |= bit (BODS); // this must be done within 4 clock cycles of above
sleep_cpu(); // sleep
cli(); // Disable interrupts
PCMSK &= ~_BV(PCINT1); // Turn off PB1 as interrupt pin
sleep_disable(); // Clear SE bit
}
ISR(PCINT0_vect) {
}
void loop()
{
sleep();
if(digitalRead(switchPin) == 1)
{
if(count >= 24)
{
flag = !flag;
digitalWrite(relayPin, flag);
count = 1;
}
else
count++;
}
}
void WDT_off(void)
{
/* Clear WDRF in MCUSR */
MCUSR = 0x00
/* Write logical one to WDCE and WDE */
WDTCR |= (1<<WDCE) | (1<<WDE);
/* Turn off WDT */
WDTCR = 0x00;
}