433mhz Transmitter and receiver without library

Hello I am using a basic 433mhz transmitter and receiver and I want to use it with an attiny85 but all the libraries take up too much RAM I was wondering if there was anyway to use the board without a library, or a way that would take up less space. Thanks in advance

Of course. :grin:

Maybe. That clearly depends on the library. :sunglasses:

Hello
Take a view to get some ideas.

Have a nice day and enjoy coding in C++.
Дайте миру шанс!

thank you but unfortunately this isn't the same board that i am using

Yes, the Arduino is programmed in C/C++, you can write your own code to do it. Any questions?

VirtualWire works fine, and will easily fit into an ATtiny85. RadioHead is not useful.

When I use the VirtualWire library I get an error (Can't compile for attiny)

Sorry to hear that!

Have you thought about posting information regarding your setup, your code, and the actual error message?

Thank you so much I am using an Attiny85 20pu
Here is my code:

#include"ServoTimer2.h"
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
ServoTimer2 servo1;
RH_ASK driver(2000, 2, 4, 5); 

void setup()
{
  servo1.attach(0);

            servo1.write(750); 
}

void loop()
{
    uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
    uint8_t buflen = sizeof(buf);

    if (driver.recv(buf, &buflen)) // Non-blocking
    {
 
      servo1.write(2300); 
       delay(3000);
       servo1.write(750);    
  int i;
 
  // Message with a good checksum received, dump it.
  driver.printBuffer("Got:", buf, buflen);
 delay(10000);
 
    }
}

Here is my error:


In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In member function 'void SPISettings::init_AlwaysInline(uint32_t, uint8_t, uint8_t)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:146:16: error: 'SPE' was not declared in this scope

 spcr = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) |

            ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:146:16: note: suggested alternative: 'SPL'

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:146:27: error: 'MSTR' was not declared in this scope

 spcr = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) |

                       ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:146:27: note: suggested alternative: 'PSTR'

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:146:65: error: 'DORD' was not declared in this scope

 spcr = _BV(SPE) | _BV(MSTR) | ((bitOrder == LSBFIRST) ? _BV(DORD) : 0) |

                                                             ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:146:65: note: suggested alternative: 'DDRB'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::beginTransaction(SPISettings)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:203:5: error: 'SPCR' was not declared in this scope

 SPCR = settings.spcr;

 ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:203:5: note: suggested alternative: 'EECR'

 SPCR = settings.spcr;

 ^~~~

 EECR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:204:5: error: 'SPSR' was not declared in this scope

 SPSR = settings.spsr;

 ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:204:5: note: suggested alternative: 'ACSR'

 SPSR = settings.spsr;

 ^~~~

 ACSR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static uint8_t SPIClass::transfer(uint8_t)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:209:5: error: 'SPDR' was not declared in this scope

 SPDR = data;

 ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:209:5: note: suggested alternative: 'EEDR'

 SPDR = data;

 ^~~~

 EEDR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:217:14: error: 'SPSR' was not declared in this scope

 while (!(SPSR & _BV(SPIF))) ; // wait

          ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:217:14: note: suggested alternative: 'ACSR'

 while (!(SPSR & _BV(SPIF))) ; // wait

          ^~~~

          ACSR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:217:25: error: 'SPIF' was not declared in this scope

 while (!(SPSR & _BV(SPIF))) ; // wait

                     ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:217:25: note: suggested alternative: 'WDIF'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static uint16_t SPIClass::transfer16(uint16_t)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:223:11: error: 'SPCR' was not declared in this scope

 if (!(SPCR & _BV(DORD))) {

       ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:223:11: note: suggested alternative: 'EECR'

 if (!(SPCR & _BV(DORD))) {

       ^~~~

       EECR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:223:22: error: 'DORD' was not declared in this scope

 if (!(SPCR & _BV(DORD))) {

                  ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:223:22: note: suggested alternative: 'DDRB'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:224:7: error: 'SPDR' was not declared in this scope

   SPDR = in.msb;

   ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:224:7: note: suggested alternative: 'EEDR'

   SPDR = in.msb;

   ^~~~

   EEDR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:226:16: error: 'SPSR' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:226:16: note: suggested alternative: 'ACSR'

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~

            ACSR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:226:27: error: 'SPIF' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

                       ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:226:27: note: suggested alternative: 'WDIF'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:230:16: error: 'SPSR' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:230:16: note: suggested alternative: 'ACSR'

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~

            ACSR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:230:27: error: 'SPIF' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

                       ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:230:27: note: suggested alternative: 'WDIF'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:233:7: error: 'SPDR' was not declared in this scope

   SPDR = in.lsb;

   ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:233:7: note: suggested alternative: 'EEDR'

   SPDR = in.lsb;

   ^~~~

   EEDR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:235:16: error: 'SPSR' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:235:16: note: suggested alternative: 'ACSR'

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~

            ACSR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:235:27: error: 'SPIF' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

                       ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:235:27: note: suggested alternative: 'WDIF'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:239:16: error: 'SPSR' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:239:16: note: suggested alternative: 'ACSR'

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~

            ACSR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:239:27: error: 'SPIF' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

                       ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:239:27: note: suggested alternative: 'WDIF'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::transfer(void*, size_t)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:247:5: error: 'SPDR' was not declared in this scope

 SPDR = *p;

 ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:247:5: note: suggested alternative: 'EEDR'

 SPDR = *p;

 ^~~~

 EEDR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:250:16: error: 'SPSR' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:250:16: note: suggested alternative: 'ACSR'

   while (!(SPSR & _BV(SPIF))) ;

            ^~~~

            ACSR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:250:27: error: 'SPIF' was not declared in this scope

   while (!(SPSR & _BV(SPIF))) ;

                       ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:250:27: note: suggested alternative: 'WDIF'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:255:14: error: 'SPSR' was not declared in this scope

 while (!(SPSR & _BV(SPIF))) ;

          ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:255:14: note: suggested alternative: 'ACSR'

 while (!(SPSR & _BV(SPIF))) ;

          ^~~~

          ACSR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:255:25: error: 'SPIF' was not declared in this scope

 while (!(SPSR & _BV(SPIF))) ;

                     ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:255:25: note: suggested alternative: 'WDIF'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::setBitOrder(uint8_t)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:292:31: error: 'SPCR' was not declared in this scope

 if (bitOrder == LSBFIRST) SPCR |= _BV(DORD);

                           ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:292:31: note: suggested alternative: 'EECR'

 if (bitOrder == LSBFIRST) SPCR |= _BV(DORD);

                           ^~~~

                           EECR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:292:43: error: 'DORD' was not declared in this scope

 if (bitOrder == LSBFIRST) SPCR |= _BV(DORD);

                                       ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:292:43: note: suggested alternative: 'DDRB'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:293:10: error: 'SPCR' was not declared in this scope

 else SPCR &= ~(_BV(DORD));

      ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:293:10: note: suggested alternative: 'EECR'

 else SPCR &= ~(_BV(DORD));

      ^~~~

      EECR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:293:24: error: 'DORD' was not declared in this scope

 else SPCR &= ~(_BV(DORD));

                    ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:293:24: note: suggested alternative: 'DDRB'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::setDataMode(uint8_t)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:298:5: error: 'SPCR' was not declared in this scope

 SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode;

 ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:298:5: note: suggested alternative: 'EECR'

 SPCR = (SPCR & ~SPI_MODE_MASK) | dataMode;

 ^~~~

 EECR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::setClockDivider(uint8_t)':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:303:5: error: 'SPCR' was not declared in this scope

 SPCR = (SPCR & ~SPI_CLOCK_MASK) | (clockDiv & SPI_CLOCK_MASK);

 ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:303:5: note: suggested alternative: 'EECR'

 SPCR = (SPCR & ~SPI_CLOCK_MASK) | (clockDiv & SPI_CLOCK_MASK);

 ^~~~

 EECR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:304:5: error: 'SPSR' was not declared in this scope

 SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((clockDiv >> 2) & SPI_2XCLOCK_MASK);

 ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:304:5: note: suggested alternative: 'ACSR'

 SPSR = (SPSR & ~SPI_2XCLOCK_MASK) | ((clockDiv >> 2) & SPI_2XCLOCK_MASK);

 ^~~~

 ACSR
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::attachInterrupt()':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:309:42: error: 'SPCR' was not declared in this scope

inline static void attachInterrupt() { SPCR |= _BV(SPIE); }

                                      ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:309:42: note: suggested alternative: 'EECR'

inline static void attachInterrupt() { SPCR |= _BV(SPIE); }

                                      ^~~~

                                      EECR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:309:54: error: 'SPIE' was not declared in this scope

inline static void attachInterrupt() { SPCR |= _BV(SPIE); }

                                                  ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:309:54: note: suggested alternative: 'ACIE'

In file included from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RadioHead.h:1169:0,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RHGenericDriver.h:9,

             from C:\Users\natan rosman\Documents\Arduino\libraries\RadioHead/RH_ASK.h:9,

             from C:\Users\natan rosman\Documents\Arduino\Alarm_Clock_Receiver\Alarm_Clock_Receiver.ino:3:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h: In static member function 'static void SPIClass::detachInterrupt()':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:310:42: error: 'SPCR' was not declared in this scope

inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); }

                                      ^~~~
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:310:42: note: suggested alternative: 'EECR'

inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); }

                                      ^~~~

                                      EECR
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,

             from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,

             from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,

             from sketch\Alarm_Clock_Receiver.ino.cpp:1:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:310:55: error: 'SPIE' was not declared in this scope

inline static void detachInterrupt() { SPCR &= ~_BV(SPIE); }

                                                   ^
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\SPI\src/SPI.h:310:55: note: suggested alternative: 'ACIE'

exit status 1

Error compiling for board ATtiny25/45/85.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


The code you posted is for the RadioHead library, which not recommended for ATtiny85.

Unless you have some special reason for using an ATtiny, don't.

I tried the VirtualWire library and got the same error do you have any recommendations on a way to run a servo and the receiver ? Thank you so much.

What is your special reason for struggling to use an ATtiny, when the code would just work on an Arduino Uno, or a $2 Pro Mini?

I want my project to be as small and cheap as possible, all the pro minis I found were 10$. I also found while using an arduino nano that it drained the battery very fast is there a way to prevent that?

Your transmitter and receiver will drain the batter faster than the nano!

how can i fix that ?

Thank you so much I really appreciate the time you took to help me

From your code in post #9, it looks like you just want to use the transmitter/receiver pair to trigger an event. The Virtualwire and Radiohead libraries are intended to transmit multi-byte messages and are designed to run as non-blocking background tasks. Thus they are more sophisticated than seems to be absolutely necessary for your application.

The TxRfSync() and RxRfSync() functions from the code in this post might be sufficient for your application and should compile fine on virtually any Arduino board. Note that all the "digitalWrite" calls in RxRfSync() in the code as presented are used only for debug/program flow demonstration and can be deleted.

The simple RF synchronization protocol in that example is blocking code which doesn't matter if your receive side Arduino isn't doing any other task. Also it's likely more susceptible to interference/false triggering than would be Virtualwire, so it might not be suitable if particularly bad or dangerous things happen on a false trigger.

Thank you. Can I delete the code for the ultrasonic sensor or is it required.

You need just the function definitions and the global variables that are used within them, the rest of the code serves as an example of how to trigger an event upon receipt of the appropriate radio signal, but you'll be changing your servo parameters rather than diddling with the ultrasonic sensor.