trouble making a program

Hi im making a program but it wont work, the meaning of the program is when i dedect a high temp +160 the robot moves to the place
i have a ping sensor en the mlx90614 module.
but the program does nothing?
im new in programming

thx.

ping_en_motor_stop_auto_met_temp_29_06.pde (5.58 KB)

xseto:
im new in programming

Well, it's time for you to learn how to debug your code. Programming like a magpie by stealing random bits of code doesn't work. Also hoping to find someone that will fix your mess for free won't work either for very long.

xseto:
but the program does nothing?

Lesson #1 in debugging: What did you change between the last time some part of the program worked and now, when it stopped working. It's very likely that the stuff you added creates the problem, so look there.

Lesson #2 in debugging: If your code never worked, throw everything away and restart from scratch. Take small steps, add features one by one and after every step test your code to make sure your code does what it should. Before you did, don't add more stuff, it makes only the mess bigger and reduces the chance to get any working code.

Lesson #3 in debugging: Write debugging output - you did that going by the numbers of prints sprinkled through your code - and read the output produced. If you say that your program does nothing, does that mean not even the LED is blinking at the start, that you get no output. If you do get some output, is the output what you expect? If yes, a good start is to look at the part of code between the last good output and the first bad or missing output. If the output gives you unexpected values, look at the code to understand why you get those values and fix it.

Lesson #4 in debugging: Debugging is work. Debugging often is no fun. Debugging is like a jigsaw puzzle where you miss half the pieces and you're not even sure if the pieces you have are from the same puzzle. Get used to it and start doing it now. If you don't want to debug, forget about programming.

Good luck.

Korman

const int pingPin = 7;            // This constant won't change.  It's the pin number of the sensor's output:
int ledpin_ok = 3;                // Green Led to visually display returned value of ping sensor.
int ledpin_close = 2;             // Red Led to display if PING Value is "Too Close" to an object.
int E1=6;          // Defines Arduino pin#6 to the pin connected to Motor Driver (PWM Pin)
int M1=7;          // Defines Arduino pin#5 to the pin connected to Motor Driver (PWM Pin)
int E2=5;          // Defines Arduino pin#9 to the pin connected to Motor Driver (PWM Pin)
int M2=4;         // Defines Arduino pin#10 to the pin connected to Motor Driver (PWM Pin)



// ***** VOID SETUP - Self Explanitory *****

void setup() {
  
//for the temp sensor 
 pinMode(2,OUTPUT);
 pinMode(3,OUTPUT);  
 pinMode(RESET,OUTPUT);

You've given some of the pins useful meaningful names (even if some of their values may be subject to change), so why don't you use them?

i made some changes to the program but now i can read temp but the motors ar not moving.

the pins where wrong.

temp_en_motor_vooruit_30_06.pde (2.63 KB)

Comments.
I really love comments.
Especially the informative ones.

AWOL:
Comments.
I really love comments.
Especially the informative ones.

i think the problem is with this “DEC” i dont know or this is the right value for the temp sensor

// IF ELSE
if (DEC <= 15) {

drive_stop(); //*FUNCTION CALL - DRIVE STOP
}else{

drive_forward(); //*FUNCTION CALL - DRIVE FORWARD
} //END OF IF STATEMENT

DEC (10) is definitely less than 15 (at least in Arduino-land)
Maybe some COMMENTS would help people understand what is going on

the meaning of the program is when a high temp is dedected the robot goes forward to it and thats it for now.
normaly this was if (DEC <= 150) { but i changed it and it still does nothing.
and the 150 is °C
i copy paste the code for the temp sensor because its complicated.

normaly this was if (DEC <= 150) { but i changed it and it still does nothing.

Normally, the expression DEC is defined by the Arduino to be ten.
What do you mean by “normaly”?

i changed it to if (DEC <= 15) { to try if it works then but it still doesnt work

i got the DEC from this piece of code
Serial.print(“Temperature”);
Serial.print(Temp3,DEC);
Serial.println(“Degrees Celsius”

but what do i need to use then for the temp reading?

DEC has the value ten.
That's why it is in the print method, to tell it to print the value "Temp3" in base 10.

ok i used temp3 in the if code, but now another problem if the temp is higher then 150 the motor keeps on goiing thats good but if its lower it goes 1sec forward en it stop en the again 1sec forward

thx for the help.