I am unable to use this LED as an indicator for when the temperature exceeds 22℃ and the motor switches on

I keep getting this error, as shown in the image. Kindly show me what code I should use to rectify this issue, and where I should place it. I'm not sure where and how I should be declaring the 'temp' variable. It seems to be okay when I placed the 'temp' variable in lines 16 and 17, but the highlighted line seems to be problematic despite being similar to lines 16 and 17.

Welcome to the forum

Please do not post pictures of code and error messages

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use [color = red]code tags[/color] (the </> icon above the compose window) to make it easier to read and copy for examination

The error message is quite clear. The temp variable has not been declared in the scope in which you try to test its value

Where is it declared and what is its scope ?

In lines 16 and 17 the temp variable is a parameter defined for the function speed_decider. Line 39 references the variable temp which has not been defined as a parameter, local variable or global.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.