0

I'm working on a project with Arduino to make LED timer with fading feature. After doing some research finally I wrote some code but it's not working until now P.S i don't have any knowledge in coding at all T_T

Edit: Adding more details about the issue; when trying to check upload this error is always shown.

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"

\SunRisetimer.ino: In function 'void loop()':

SunRisetimer:55: error: 'startOff' was not declared in this scope

     startOff();
\SunRisetimer.ino: In function 'void startOn()':

SunRisetimer:89: error: variable or field 'startOff' declared void

 void startOff

SunRisetimer:91: error: expected '}' before ';' token

analogWrite(uled, 1);

SunRisetimer:116: error: expected '}' at end of input

 }
exit status 1
'startOff' was not declared in this scope

Code:

#include <DS3231.h> //Include the clock library

// Changable Vars
int fadeTimeOn = 30; // How long the light will fade to max
int fadeTimeOff = 30; // How long the light will fade to min
int setHourOn = 9; // Set hours to wake (military time)
int setMinOn = 15; // Set minute to wake
int setHourOff = 9; //set off h
int setMinOff = 30; //
int uled = 9; // Set pinout with with PWM

// Set up Vars
DS3231  rtc(SDA, SCL);
Time t;
void start();

void setup()
{
  pinMode(uled, OUTPUT);
  Serial.begin(9600); // Match to serial monitor
  rtc.begin();
}

void loop()
{
  t = rtc.getTime(); // Make a time class called 't'

  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");

  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());

  if (t.hour == setHourOn && t.min == setMinOn) // Check if it's time to wake up!
  {
    startOn();
  }

  // Wait one second before repeating
  delay (1000);


 if (t.hour == setHourOff && t.min == setMinOff) // Check if it's time to off!
  {
    startOff();
  }

  // Wait one second before repeating
  delay (1000);
}

void startOn()
{
  // Fix for SB LED
  analogWrite(uled, 1);
  delay((fadeTimeOn * 60000)/50);
  analogWrite(uled, 2);
  delay((fadeTimeOn * 60000)/50);
  analogWrite(uled, 3);
  delay((fadeTimeOn * 60000)/50);
  analogWrite(uled, 4);
  delay((fadeTimeOn * 60000)/50);
  analogWrite(uled, 4);
  delay((fadeTimeOn * 60000)/50);
  analogWrite(uled, 5);
  delay((fadeTimeOn * 60000)/50);

for (int i = 6 ; i <= 255; i++)
    {
    analogWrite(uled, i);
    delay(((fadeTimeOn * 60000)/306));
    Serial.print(" mil sec ");
    Serial.print(((fadeTimeOn * 60000)/306));
    Serial.print(" PWM " );
    Serial.print(i);
    {
}

void startOff
{
  analogWrite(uled, 1);
  delay((fadeTimeOff * 60000)/50);
  analogWrite(uled, 5);
  delay((fadeTimeOff * 60000)/50);
  analogWrite(uled, 4);
  delay((fadeTimeOff * 60000)/50);
  analogWrite(uled, 3);
  delay((fadeTimeOff * 60000)/50);
  analogWrite(uled, 2);
  delay((fadeTimeOff * 60000)/50);
  analogWrite(uled, 1);
  delay((fadeTimeOff * 60000)/50);

  // Fade script
  for (int i = 6 ; i <= 255; i++)
  {
    analogWrite(uled, i);
    delay(((fadeTimeOff * 60000)/306));
    Serial.print(" mil sec ");
    Serial.print(((fadeTimeOff * 60000)/306));
    Serial.print(" PWM " );
    Serial.print(i);

  }

}
4
  • 1
    "it's not working" is not a useful description of the problem. Please edit your question to provide specific details.
    – per1234
    Feb 11 '18 at 4:29
  • sorry for not gifting the complete information :) error log put in the post now
    – kamal
    Feb 11 '18 at 7:06
  • 1
    What you have are compiling errors, not "problems making it fade". For example, you need to put "()" when declaring the startOff function. Things like that, elementary syntax.
    – user31481
    Feb 11 '18 at 8:42
  • 3
    I'm voting to close this question as off-topic because this is not a programming school.
    – user31481
    Feb 11 '18 at 8:43
1

Look at your function definitions:

void startOn() // works
void startOff    // doesn't work

You are missing the () after startOff.

1
  • great its work even tough its not dim out and off but it make me one step ahead. thanks
    – kamal
    Feb 11 '18 at 15:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.