OK - Its actually work !!
I refrshed the web browser and did what you asked and now the new sketch ("hello world" sketch ) is working.
here is my original code/ Can someone understand where is the problem with it ?
/*
Sketch generated by the Arduino IoT Cloud Thing "LED"
https://create.arduino.cc/cloud/things/a3799e6c-75da-4de8-b7d4-a137dd0a327e
Arduino IoT Cloud Properties description
The following variables are automatically generated and updated when changes are made to the Thing properties
bool LED;
bool stepRight;
float pressure;
float flow;
Properties 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 LED_PIN 2
int PressurePin = 5;
int flowsensor = 4; // Sensor Input
boolean dir = true;// gre
volatile int flow_frequency; // Measures flow sensor pulses
unsigned int l_hour; // Calculated litres/hour
unsigned long currentTime;
unsigned long cloopTime;
//motor
//======
// Setup the builtin LED, the step and direction pins.
const int stepPin = 9;
const int dirPin = 1;
// Set the PWM duty cycle and counter pin.
const int dutyCycle = 25;
const int counterPin = 0 ;
const int gearRatio = 26.85; //for the large motor
const int stepAngle = 1.8 ; //degrees
const int microStepRatio = 0.25; //current configuratoin of pollulu with M0 and M1 floating
const int stepsPerRevolution = (360/stepAngle)*(1/microStepRatio)*gearRatio;
// Define step targets and counters.
int stepTarget;
volatile int stepsTaken = 0;
// Store the direction the stepper is moving (one or zero).
int stepperDir;
void setup() {
// 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);
pinMode(flowsensor, INPUT_PULLUP);
pinMode(4, INPUT);
//digitalWrite(flowsensor, HIGH);
attachInterrupt(digitalPinToInterrupt(flowsensor), flowf, RISING ); // Setup Interrupt
interrupts() ;// Enable interrupts
currentTime = millis();
cloopTime = currentTime;
//Motor
//======
// Setup the stepper.
pinMode(dirPin, OUTPUT);
digitalWrite(dirPin, LOW);
pinMode(stepPin, OUTPUT);
stepperDir = 1;
/*
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();
pinMode(LED_PIN, OUTPUT);
//pinMode(Pin0, OUTPUT);
//pinMode(Pin1, OUTPUT);
//pinMode(Pin2, OUTPUT);
//pinMode(Pin3, OUTPUT);
}
void flowf () // Interrupt function
{
flow_frequency++;
}
void loop() {
ArduinoCloud.update();
// Your code here
int sensorVal=analogRead(PressurePin);
float voltage = (sensorVal5.0)/1024.0;
float pressure_pascal = (3.0((float)voltage-0.46))1000000.0; //calibrate here - recalibrated from 0.475 to 0.46
float pressure_bar = pressure_pascal/10e5;
pressure = pressure_bar14.5038;
currentTime = millis();
// Every second, calculate and print litres/hour
if(currentTime >= (cloopTime + 1000))
{
cloopTime = currentTime; // Updates cloopTime
// Pulse frequency (Hz) = 7.5Q, Q is flow rate in L/min.
l_hour = (flow_frequency * 60 / 7.5); // (Pulse frequency x 60 min) / 7.5Q = flowrate in L/hour
l_hour = (flow_frequency * 60 / 10); // (Pulse frequency x 60 min) / 10Q = flowrate in L/hour - acording to the datsheet of our flow meter
flow=l_hour;
flow_frequency = 0; // Reset Counter
Serial.print(currentTime, DEC); // time stamp
Serial.print(" , ");
Serial.print(l_hour, DEC); // Print litres/hour
Serial.print(" ,L/hour,");
Serial.print("Pressure = ,");
Serial.print(pressure_bar);
Serial.print(" , bars, ");
Serial.print ("psi, ");
Serial.print (pressure);
Serial.println();
}
}
void onLEDChange() {
// Do something
digitalWrite(LED_PIN, LED);
Serial.print("The light is ");
if (LED) {
Serial.println("ON");
} else {
Serial.println("OFF");
}
}
void onStepRightChange() {
//set direction clockwise
if (stepperDir == 1 ) {
digitalWrite(dirPin, HIGH );
stepperDir = 0;
} else {
digitalWrite(dirPin, LOW );
stepperDir = 1;
}
Serial.println("stepping");
Serial.println(stepsPerRevolution);
//digitalWrite(dirPin, LOW );
//stepperDir = 1;
for (int x=0; x<stepsPerRevolution ; x++) //stepsPerRevolution 21480
{
digitalWrite(stepPin, HIGH);
delayMicroseconds(2000);
digitalWrite(stepPin, LOW);
delayMicroseconds(2000);
//Serial.println("stepping");
}
}