current transformer switch relay (errormessage)

I have copied a sketch from a youtube video and its the first sketch for me.

I want to do the exact same thing as in the video, switching a relay when AC current is detected to control a fan.

Im stuck with the code tho, it will not compile the sketch, just a lot of error messages. Any help is appriciated.

Here is the error message:

Arduino:1.8.5 (Windows Store 1.8.10.0) (Windows 10), Kort:"Arduino Nano, ATmega168"

C:/CTfet.ino: In function 'void loop()':

CTfet:76: error: expression cannot be used as a function

RELAY1 (ON);

^

CTfet:81: error: expression cannot be used as a function

RELAY1 (OFF);

^

CTfet:87: error: 'relayState' was not declared in this scope

if (relayState == OFF) {

^

C:CTfet.ino: At global scope:

CTfet:106: error: expected initializer before 'if'

if (desiredState == relayState) {

^

CTfet:111: error: expected unqualified-id before 'if'

if (desiredState == ON) if ( abs(millis() - switch_request_time) > 3000 ) {

^

CTfet:121: error: expected unqualified-id before 'if'

if (desiredState == OFF) if ( abs(millis() - switch_request_time) > 8000 ) {

^

CTfet:130: error: expected declaration before '}' token

}

^

exit status 1
expression cannot be used as a function

CTfet.ino (3.78 KB)

This is not the way to do it . You need to play with your Arduino and run the examples, learn how they work , learn how to code and debug stuff . Downloading something off the web that you don’t understand is not the way to do it and makes it hard to help- the web is full of stuff that doesn’t work.

Sorry

OpenSourceE:
I want to do the exact same thing as in the video, switching a relay when AC current is detected to control a fan.

Sold as "green powerboard".
Leo..