Page 1 of 1

Going crazy over Gpio....

Posted: Tue Oct 10, 2017 3:40 am
by notso2slo
So I have been trying to get my oil warning light working, and have been really struggling... No matter what I do, the Gpio seems to be in a state of 0.

So I finally simplified my code down to this:

Code: Select all

function onTick()
   setGpio(0, 1)
   println("Oil Warn " ..getGpio(0))
 end
And still, all I see returned is:
Oil Warn 0.0

What am I doing wrong??? The channel is on, the sample rate is 1hz, and the mode is output....

Going crazy here!

Posted: Tue Oct 10, 2017 2:50 pm
by ross2004
You have no scripting for checking the oil pressure/temp it looks like. From the Wiki, you'd need something like this:

Code: Select all

function onTick()
 if getAnalog(0) > 212 then
   setGpio(0, 1)
 else
   setGpio(0, 0)
 end
end

Posted: Tue Oct 10, 2017 5:31 pm
by notso2slo
I was attempting to eliminate excess steps, so instead of using logic to determine whether or not to set the Gpio to 0 or 1, I just go ahead and set it to 1.

It wasn't working with the logic, so I just set it as a constant.

Posted: Wed Oct 11, 2017 1:01 am
by notso2slo
So I think the problem goes deeper....

I have a race capture MK1, and I plugged that in and loaded that code. I get a return of 1 instead of 0 now....

Posted: Tue Oct 17, 2017 2:28 pm
by brentp
For MK1, you have to set the GPIO to output mode via the internal jumpers, and set the configuration to 'output'.

When GPIO is activated (1) it connects the output to ground. You can test it by driving a relay where the ground side of the relay is powered via the GPIO.

Hope this helps!