Pressure Switch code

I am having a problem with our compressor, spikes, and RC. I need to get the pressure switch to tell the spike that is connected to the compressor to turn on unto it read 120psi. Yet I don’t even have a spike switching to fwd or rev?

I have this code in right now

				if(digital_io_18 == 0)
						{
							relay1_fwd == 1;
						}

				if(digital_io_18 ==1)
						{
							relay1_fwd == 0;
						}

Can some let me know what I am doing wrong?

Thank you

Your if statements match mine but I think it should be relay1_fwd = 1; not relay1_fwd == 1;

== is for comparing, = is for assigning values

If thats not it, double check that you have the digital i/o set to input. Also check that your code is actually being called. I had my code in user_routines.c/default_routine() which wasn’t being called, once i stuck the code in user_routines.c/Process_Data_From_Master_uP() it worked. Also make sure your not in disabled mode. I made the that mistake earlier this week

user_routines.c/User_Initialization()
digital_io_18 = INPUT; //DIGITAL I/O set to input;

Good luck

Along with the == vs = confusion, you’re reading the wrong thing to test the pressure switch. Writing to digital_io_18 is for configuring the pin as either an input or an output. You want read from rc_dig_in18, which gives you the value of the pin.

You can just do it all in one line.

relay1_fwd=!rc_dig_in18

-Don