Why am I getting this error? I'm beginner please help
/
*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/c9c62035-ec26-46e0-8a21-c2c322a975db
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float valueMesafe;
int valueRandom;
bool stateRole;
bool stateRole2;
bool stateRole3;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#define trigPin D6
#define echoPin D7 //hcsr04 icin gerekli
long duration, distance; //hcsr04 icin gerekli
#define pinRole D4 //role icin gerekli:
#define pinRole2 D3 //role icin gerekli:
#define pinRole3 D5 //role icin gerekli:
void setup() {
pinMode(pinRole,OUTPUT); //role icin gerekli:
pinMode(pinRole2,OUTPUT); //role icin gerekli:
pinMode(pinRole3,OUTPUT); //role icin gerekli:
pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); //hcsr04 icin gerekli
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
}
void loop() {
fcnMesafe(); //hcsr04 icin gerekli
valueMesafe = distance;
valueRandom = random(1000);
ArduinoCloud.update();
delay(250);
}
/*
Since StateRole is READ_WRITE variable, onStateRoleChange() is
executed every time a new value is received from IoT Cloud.
*/
void onStateRoleChange() {
if(stateRole) digitalWrite(pinRole,LOW); else digitalWrite(pinRole,HIGH); //role icin gerekli:
}
void onStateRole2Change() {
if(stateRole2) digitalWrite(pinRole2,LOW); else digitalWrite(pinRole2,HIGH); //role icin gerekli:
}
void onStateRole3Change() {
if(stateRole3) digitalWrite(pinRole3,LOW); else digitalWrite(pinRole3,HIGH); //role icin gerekli:
}
void fcnMesafe()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed of sound.
distance = duration/58.2;
if(distance>199) distance =999;
if(distance<5) distance=999;
Serial.println(distance);
//Delay 50ms before next reading.
delay(50);
}
Hi @osmankucukoglu. I'm going to ask you to post some additional information that might help us to identify the problem.
NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.
Please do this:
In the sketch panel, click the (verify) button.
After the compilation fails, click the icon in the top right corner of the black console window at the bottom of the Arduino Cloud editor window that looks like two pieces of paper.
In a forum reply here, click on the reply field.
Click the <CODE/> button on the forum toolbar.
This will add the forum's code block markup (```) to your reply to make sure the compilation output is correctly formatted.
Press Ctrl+V.
This will paste the compilation output between the code tags.
Move the cursor outside of the code tags before you add any additional text to your reply.
Click the Reply button to post the output.
In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:
Open a forum reply here by clicking the Reply button.
Click the "Upload" icon () on the post composer toolbar:
A dialog will open.
In the dialog, select the .txt file you saved.
Click the Open button.
Click the Reply button to publish the post.
Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.
You have configured your Arduino IoT Cloud "Thing" to use the "Cloud Variables" valueMesafe and valueRandom. The Thing sketch that was generated when you created the Thing in Arduino IoT Cloud contained some functions that would be called whenever the value of those variables changed:
onValueMesafeChange()
onValueRandomChange()
It seems you have deleted those functions from your sketch. You must add them back to the sketch. Once you have done that, the error will no longer occur when you attempt to compile the sketch.
Did you add the functions back to your sketch code? They aren't present in the sketch code you shared in post #1. The "undefined reference" compilation errors you encountered are expected when compiling that sketch because indeed the code doesn't contain any definitions of those referenced functions.