Can you spot what's wrong with this code???

Hi all ,
i have absolutely no knowledge about code, and i am trying to replicate a small project that i found online (https://www.hackster.io/KaustubhAgarwal/smart-doorbell-364e28) and was described as “easy”…
I am using an ARDUINO UNO R3 plus a generic ethernet shield named " HanRun, HR911105A,15\10", downloaded the current Arduino-Nightly release from July (the current stable version would not install and kept showing errors), Blinky (latest version), and my laptop is using Widows 7.
The standard sample sketch called ethernet shield or something similar is uploading correctly and all the little multicoloured leds are on or blinking, on my Iphone 5, the Blink app it shows that the button is online, so that should be a good sign, but i am unable to upload this code that will alert me anytime would ring the bell…can anyone please help?
Thanks

#define BLYNK_PRINT Serial
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "this is my token number";

SimpleTimer timer;

WidgetLCD lcd(V1);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);

  while (Blynk.connect() == false) {
    // Wait until connected
  }
}
void notifyOnButtonPress()
{
  // Invert state, since button is "Active LOW"
  int isButtonPressed = !digitalRead(2);
  if (isButtonPressed) {
    BLYNK_LOG("Button is pressed.");

    Blynk.notify("Please open up! Somebody is on the door!");
     lcd.clear(); //Use it to clear the LCD Widget
  lcd.print(4, 0, "Open"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd.print(4, 1, "The Door!");
  }
}

void emailOnButtonPress()
{

  int isButtonPressed = !digitalRead(2); // Invert state, since button is "Active LOW"

  if (isButtonPressed) // You can write any condition to trigger e-mail sending
  {
    BLYNK_LOG("Button is pressed."); // This can be seen in the Serial Monitor
    Blynk.email("thisis@myemail.com", "Subject: Doorbell", "Please open up! Somebody is on the door!");
     lcd.clear(); //Use it to clear the LCD Widget
  lcd.print(4, 0, "Open"); // use: (position X: 0-15, position Y: 0-1, "Message you want to print")
  lcd.print(4, 1, "The Door!");

  }
}

void loop() {
  // put your main code here, to run repeatedly:
  Blynk.run();
  timer.run();
}

}

RETARDUINO: i am unable to upload this code that will alert me anytime would ring the bell....can anyone please help?

What do you mean by "unable to upload"?!? Do you get an error message? What do the error messages say?!?

RETARDUINO: i have absolutely no knowledge about code, and i am trying to replicate a small project that i found online

IMHO it is unreasonable to expect to get something working when you have no knowledge about how to do it. That is why people pay professionals.

On the other hand if you would like to acquire the necessary knowledge we will be happy to help. However I suggest you start with something simpler, such as the examples that come with the Arduino IDE.

...R

RETARDUINO: i have absolutely no knowledge about code, and i am trying to replicate a small project that i found online (https://www.hackster.io/KaustubhAgarwal/smart-doorbell-364e28) and was described as "easy"....

That article makes no sense. There is a photo of some sort of camera which would enable the smartphone to see who rang the door bell. Yet, there is no mention of it in the parts list.

The only thing you are going to be able to get on your smartphone is a message that the button was pressed. You won't see who is at the front door.

Anyway, the comments show that people are having problems with the sketch.

RETARDUINO: Hi all , ... i am trying to replicate a small project that i found online (https://www.hackster.io/KaustubhAgarwal/smart-doorbell-364e28) ... please help? Thanks

First of all you need a blynk account and blynk library installed. Have a look at the comments to that project. Plenty of comments about problems.

Picture is a Skybell video doorbell. Completely unrelated to that project.

Copied the sketch from Hackster.io. First set of errors:

Arduino: 1.8.2 (Mac OS X), Board: "Arduino/Genuino Uno"

/Users/john/Documents/Arduino/sketch_jul09a/sketch_jul09a.ino:4:33: fatal error: BlynkSimpleEthernet.h: No such file or directory
 #include <BlynkSimpleEthernet.h>
                                 ^
compilation terminated.

Used Library Manager to install V0.4.8 of the BLYNK library. Second set of errors:

Arduino: 1.8.2 (Mac OS X), Board: "Arduino/Genuino Uno"

Build options changed, rebuilding all
/Users/john/Documents/Arduino/sketch_jul09a/sketch_jul09a.ino:5:25: fatal error: SimpleTimer.h: No such file or directory
 #include <SimpleTimer.h>
                         ^
compilation terminated.

Library Manager has no matches for SimpleTimer. Had to try a Google search for: SimpleTimer library arduino. First hit: https://playground.arduino.cc/Code/SimpleTimer Copied SimpleTimer.h and SimpleTimer.cpp to new tabs in the sketch window. Changed <SimpleTimer.h> to “SimpleTimer.h” to allow it to find the library in the sketch folder. Compiled with only warnings:

sketch/SimpleTimer.cpp: In member function 'void SimpleTimer::run()':
sketch/SimpleTimer.cpp:66:49: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (current_millis - prev_millis[i] >= delays[i]) {
                                                 ^
/Applications/Arduino1.8.2.app/Contents/Java/libraries/Ethernet/src/utility/socket.cpp:365:19: warning: unused parameter 's' [-Wunused-parameter]
 void flush(SOCKET s) {
                   ^
Sketch uses 18646 bytes (57%) of program storage space. Maximum is 32256 bytes.
Global variables use 994 bytes (48%) of dynamic memory, leaving 1054 bytes for local variables. Maximum is 2048 bytes.

The first warning can be fixed by changing one line in SimpleTimer.h from

    // delay values
   long delays[MAX_TIMERS];

to

    // delay values
    unsigned long delays[MAX_TIMERS];

Gabriel_swe: Picture is a Skybell video doorbell. Completely unrelated to that project.

The writer of that "article" had some nerve putting a photo of the Skybell. Talk about bait and switch.

The next step is to sign up for a BLYNK account and get an authorization key.

http://www.blynk.cc/getting-started/

yeah, it seems like the way to tackle this project would be to first get a good understanding of how to use blynk. I would do a small project that will help you understand how blynk works. maybe start by using blynk to ring your doorbell at home. that would be as simple as using the arduino, through blynk, to activate a relay wired into the doorbell button circuit. the button at your front door would be wired in parrellel with the relay. You could probably install the arduino and relay inside the doorbell chime housing if it is not too small. Then I would t-tap the switch leg of the doorbell button to activate the relay, while supplying 5v to the common relay terminal and then monitor the NO terminal on the relay with the arduino, probably do this through a pull up resistor. Once you can use the arduino to say hey the doorbell rang, I need to interact with the smartphone, you can add in a camera. But that seems like a tough first project bud.

That article is BS, designed to generate traffic. It’s clickbait.

johnwasser: What do you mean by "unable to upload"?!? Do you get an error message? What do the error messages say?!?

Yes i get an error on the Arduino consolle, i forgot to take a note on what it did say exactly, was something wrong with the code, i will post the exact words soon, thanks

Robin2: IMHO it is unreasonable to expect to get something working when you have no knowledge about how to do it. That is why people pay professionals.

On the other hand if you would like to acquire the necessary knowledge we will be happy to help. However I suggest you start with something simpler, such as the examples that come with the Arduino IDE.

...R

If your intent it's willing to put off people, that was a nice try, luckily there are other knowleadgeable users that are willing to help.... Some ppl should bear in mind, that if a "gadget" is perceived as something too difficult to handle or which require more efforts that the average user would like to put into it, that surely will not attract potential buyers, while on the other hand, if the opposite it's true, money will start flow in, giving more resources to expand even more these projects. As you mentioned some financial aspects, i thought this very basic concept would be of your interest, as you are not exactly doing a favour to a project you presumably enjoy, supporting that kind of mindset...

ieee488: That article makes no sense. There is a photo of some sort of camera which would enable the smartphone to see who rang the door bell. Yet, there is no mention of it in the parts list.

The only thing you are going to be able to get on your smartphone is a message that the button was pressed. You won't see who is at the front door.

Anyway, the comments show that people are having problems with the sketch.

Yes i noticed that too, the tutorial is very "sketchy", the little resistor and apparently even a diode are not mentioned at all in the part's list, however they are seen on the picture, plus the creator of it doesn't answer the various questions... I had the feeling that it might even be a "fake" of some sorts, as the many seen on Youtube, but then why the website would put it on their list as "legit"? Surely some of the experts managing the site would have spotted it and not published? Right now the Blinky app on my phone is detecting as "online" the button, which is a good sign, but it seems there is something wrong on that code, as every time i try to upload it to the Arduino board, it just doesn't do it and tells me there is something wrong. All i need it's something that alert me on my phone, whenever someone press a button, and i do not want to pay for sms messages or similar, it must to be a free alerter...

RETARDUINO (Why not pick a handle that isn't offensive? Just askin'.), it depends on what you want.

If you all you want want is a bell photo thingy for your door, get a commercial product. If it isn't available commerically, hire someone.

But if you want to be able to do it yourself, if you want to learn to code and hack devices - great! Start with the tutorial sketches. They are there for a reason. I also suggest googling "C++ tutorial" and learning the basics of the programming language - just the first few chapters.

johnwasser:
Copied the sketch from Hackster.io. First set of errors:

Arduino: 1.8.2 (Mac OS X), Board: "Arduino/Genuino Uno"

/Users/john/Documents/Arduino/sketch_jul09a/sketch_jul09a.ino:4:33: fatal error: BlynkSimpleEthernet.h: No such file or directory
#include <BlynkSimpleEthernet.h>
                                ^
compilation terminated.




Used Library Manager to install V0.4.8 of the BLYNK library. Second set of errors:

Arduino: 1.8.2 (Mac OS X), Board: “Arduino/Genuino Uno”

Build options changed, rebuilding all
/Users/john/Documents/Arduino/sketch_jul09a/sketch_jul09a.ino:5:25: fatal error: SimpleTimer.h: No such file or directory
#include <SimpleTimer.h>
                        ^
compilation terminated.



Library Manager has no matches for SimpleTimer. Had to try a Google search for: SimpleTimer library arduino. First hit: https://playground.arduino.cc/Code/SimpleTimer Copied SimpleTimer.h and SimpleTimer.cpp to new tabs in the sketch window. Changed <SimpleTimer.h> to "SimpleTimer.h" to allow it to find the library in the sketch folder. Compiled with only warnings:

sketch/SimpleTimer.cpp: In member function ‘void SimpleTimer::run()’:
sketch/SimpleTimer.cpp:66:49: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
            if (current_millis - prev_millis[i] >= delays[i]) {
                                                ^
/Applications/Arduino1.8.2.app/Contents/Java/libraries/Ethernet/src/utility/socket.cpp:365:19: warning: unused parameter ‘s’ [-Wunused-parameter]
void flush(SOCKET s) {
                  ^
Sketch uses 18646 bytes (57%) of program storage space. Maximum is 32256 bytes.
Global variables use 994 bytes (48%) of dynamic memory, leaving 1054 bytes for local variables. Maximum is 2048 bytes.



The first warning can be fixed by changing one line in SimpleTimer.h from 

// delay values
  long delays[MAX_TIMERS];



to 

// delay values
    unsigned long delays[MAX_TIMERS];

Thanks!
I am going to try to make sense of it and upload it to see how it goes, as i mentioned, my coding skills are zero or close to it, my guess is that i will have to edit those error and attach it somewhere to the code i posted, maybe at the bottom of it?

roosterqmoney: That article is BS, designed to generate traffic. It's clickbait.

Really? So it's a fake then? I hope not, as i really need something like that and i thought an Arduino would be able to handle it somehow.....

GEEZ WHO THE HECK PUT THIS RESTRICTION ON THE FORUM WHERE AN USER CAN ONLY WRITE A SINGLE REPLY EVERY 5 MINUTES??? THAT'S ABSOLUTELY RIDICOLOUS! I would like to reply to every single person that replied to me, just as for showing some manners if not anything else, but i surely do NOT want to come here EVERY 5 MINUTES to post a reply, just how annoying is that? there is anyway to change it? Please do not think that i am ignoring your posts if i do not reply to you when you see me online, it's because of this crazy forum settings.....

PaulMurrayCbr: RETARDUINO (Why not pick a handle that isn't offensive? Just askin'.), it depends on what you want.

If you all you want want is a bell photo thingy for your door, get a commercial product. If it isn't available commerically, hire someone.

But if you want to be able to do it yourself, if you want to learn to code and hack devices - great! Start with the tutorial sketches. They are there for a reason. I also suggest googling "C++ tutorial" and learning the basics of the programming language - just the first few chapters.

Why should you feel offended? That's just my nickname, so it refers to me, if you see something on it that makes you feels as it should point to your own person, let me know where and i'll see what i can do about it, take it easy, life's short, just having some fun :)))

I do not need a photo, all i want is a phisycal button that when it get pressed, send something to my phone, it can even swear i don't mind, but it should not charge me as i am already skint after having purchased the board and the shield, and possibly without any wiring attached between my phone and the door bell, otherwise i would have simply tightened my phone to a rope and put a sign on the entrance to pull it when coming in, must to be wireless

RETARDUINO: GEEZ WHO THE HECK PUT THIS RESTRICTION ON THE FORUM WHERE AN USER CAN ONLY WRITE A SINGLE REPLY EVERY 5 MINUTES??? THAT'S ABSOLUTELY RIDICOLOUS!

I know its a PITA but it was introduced to stop spammers and apparently it is very effective. The limitation goes away after your 100th post (IIRC).

You can respond to several people in a single post. Maybe compose your Reply in a text editor and when you are happy with it just copy and paste into the reply window.

...R

RETARDUINO:
Why should you feel offended?

I’d like to reply to this, but I don’t think I can do it without being rude myself.

RETARDUINO:
I am using an ARDUINO UNO R3 plus a generic ethernet shield

I do not need a photo, all i want is a phisycal button that when it get pressed, send something to my phone,

Well, it looks like that’s what blynk does. You’d connect the ardiuino to a hub or router that has a route out to the internet … oh, hang on: you already have all that.

Cool. So the issue seems to be this “simpletimer” thing.

You know - as far as I can see, this sketch isn’t using the timer at all!

Just get rid of

#include <SimpleTimer.h>
…
SimpleTimer timer;
…
  timer.run();

You just don’t need them as far as I can see.