hello!
I'm a beginner in Arduino, and I have a ultrasonic sensor JSN-SR04t, and I'm using it to measure a volume of a reservoir and I tested the functionability of the sensor sending information to the Arduino APP, and everything is working fine, however I need to send the same information that I have in my computer (Arduino App) to a CLP, then I need to know how could be the insctrucion in the Arduino code to enable the output of the PWM of Arduino Uno.
Because of the CLP inlet tension is 24 Vcc, I will need to have a driver or something to increase up the voltage from 5 Vcc to 24 Vcc, but It I can solve later, what I really need now is to enable the PWM output with the proper code. The code that I'm using to my ultrasonic sensor to communicate with my Arduino APP (PC) I copied from internet and I did some modifications. Bellow follow the code:
obs.: the volu
#define trigPin 12
#define echoPin 11
float duration, volume;
void setup() {
Serial.begin (9600);
pinMode (trigPin,OUTPUT);
pinMode (echoPin,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// medindo o sensor ultrasônico
duration = pulseIn(echoPin, HIGH);
// determinar a distância a partir da duração
// velocidade do som 343 m/s
volume = ((49087.5 * (336 - (duration / 2) * 0.0343)) / 1000) * 1.2;
// enviando resultado para o Arduino
Serial.print("volume = ");
if (volume >= 20000 || volume <= 2) {
Serial.println("out of range");
}
else {
Serial.print(volume);
Serial.println(" litros");
delay(500);
}
delay(500);
}