Confusion with ULN2803 and IR sensor power
-
- Posts: 581
- Joined: Mon Sep 07, 2020 8:49 am
Re: Confusion with ULN2803 and IR sensor power
So where do I place this snippet of your code in the code that Keith gave me today?jph wrote: ↑Sun Aug 14, 2022 7:53 pmI knew there must be a cleaner way - a bit more boolean, it works this time thoughCode: Select all
function input_change1(state) log(state) state = not state log(state) end
Re: Confusion with ULN2803 and IR sensor power
Naw, its just that I use C++ (Arduino flavoured) all the time. As said, I don't use the AM flashed arduinos of any kind, all direct comms for any hardware so never use the built in stuff at all.Kaellis991 wrote: ↑Sun Aug 14, 2022 7:54 pm
It looks pretty clean to this greenhorn...
Keith did tell me today that there are many things in LUA that the AM developers did not implement in Air Manager. Maybe what you are trying to do is one of those omitted capabilities.
as for placement, just lose both of those you have - comment all that out and put the code below in there instead. it should be logical ? he said haha
Code: Select all
-- create output
outp_id = hw_output_add("My output",false)
function input_change1(state)
log(state)
state = not state
log(state)
hw_output_set(outp_id,state)
end
-- create input
position_1 = hw_input_add("My input 1", input_change1)
Joe. CISSP, MSc.
-
- Posts: 581
- Joined: Mon Sep 07, 2020 8:49 am
Re: Confusion with ULN2803 and IR sensor power
jph wrote: ↑Sun Aug 14, 2022 8:05 pmNaw, its just that I use C++ (Arduino flavoured) all the time. As said, I don't use the AM flashed arduinos of any kind, all direct comms for any hardware so never use the built in stuff at all.Kaellis991 wrote: ↑Sun Aug 14, 2022 7:54 pm
It looks pretty clean to this greenhorn...
Keith did tell me today that there are many things in LUA that the AM developers did not implement in Air Manager. Maybe what you are trying to do is one of those omitted capabilities.
as for placement, just lose both of those you have - comment all that out and put tcode below in there instead.
Code: Select all
-- create output outp_id = hw_output_add("My output",false) function input_change1(state) log(state) state = not state log(state) end -- create input position_1 = hw_input_add("My input 1", input_change1)
Sorry Joe,
This is what I am getting now....each time I cover the sensor I get True False ...False True....True False....ad infinitum...the LED never activates now.
Oh well, maybe some other day it can get sorted out. It's time for me to grill up my dinner....
Re: Confusion with ULN2803 and IR sensor power
Check the post just before your last, you are missing a line of code,... the bit that controls the led.
Also, the true false false true true etc is correct for the log output as it is showing the entry and change state. Just remove the second log line if its confusing.
As for what happens then I have no idea as i dont have the sensor .. is the output pusled or constant? Anyway, the output in the console is correct for the 2 log lines, as said, remove one to make it easier to read.
Also, the true false false true true etc is correct for the log output as it is showing the entry and change state. Just remove the second log line if its confusing.
As for what happens then I have no idea as i dont have the sensor .. is the output pusled or constant? Anyway, the output in the console is correct for the 2 log lines, as said, remove one to make it easier to read.
Joe. CISSP, MSc.
-
- Posts: 581
- Joined: Mon Sep 07, 2020 8:49 am
Re: Confusion with ULN2803 and IR sensor power
Yes sir, I was just posting that I found that omission.jph wrote: ↑Sun Aug 14, 2022 8:33 pm Check the post just before your last, you are missing a line of code,... the bit that controls the led.
Also, the true false false true true etc is correct for the log output as it is showing the entry and change state. Just remove the second log line if its confusing.
As for what happens then I have no idea as i dont have the sensor .. is the output pusled or constant? Anyway, the output in the console is correct for the 2 log lines, as said, remove one to make it easier to read.
-
- Posts: 581
- Joined: Mon Sep 07, 2020 8:49 am
Re: Confusion with ULN2803 and IR sensor power
Joe,jph wrote: ↑Sun Aug 14, 2022 8:33 pm Check the post just before your last, you are missing a line of code,... the bit that controls the led.
Also, the true false false true true etc is correct for the log output as it is showing the entry and change state. Just remove the second log line if its confusing.
As for what happens then I have no idea as i dont have the sensor .. is the output pusled or constant? Anyway, the output in the console is correct for the 2 log lines, as said, remove one to make it easier to read.
It works as it should now. The LED lights up when I cover the sensor as it should. Thank you for all your expertise.
Don't you love it when a plan comes together?
Re: Confusion with ULN2803 and IR sensor power
No worries , Glad u got sorted. Enjoy your dinner
Joe
Joe
Joe. CISSP, MSc.
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Confusion with ULN2803 and IR sensor power
Hi,
Sorry Kirk. I had a short nap. Just add a not to swap the output state.
I see Joe assisted
Keith
Sorry Kirk. I had a short nap. Just add a not to swap the output state.
I see Joe assisted
Code: Select all
-- Create a new output 1
led1 = hw_output_add("My output led 1", true)
-- Create a new input 1
hw_input_add("My input 1",function(state)
hw_output_set(led1, not state)
end)
---------------------------------------------------------------
-- Create a new output 2
led2 = hw_output_add("My output led 2", true)
-- Create a new input 2
hw_input_add("My input 2",function(state)
hw_output_set(led2, not state)
end)
---------------------------------------------------------------
-- Create a new output 3
led3 = hw_output_add("My output led 3", true)
-- Create a new input 3
hw_input_add("My input 3",function(state)
hw_output_set(led3, not state)
end)
---------------------------------------------------------------
-- Create a new output 4
led4 = hw_output_add("My output led 4", true)
-- Create a new input 4
hw_input_add("My input 4",function(state)
hw_output_set(led4, not state)
end)
Last edited by Keith Baxter on Sun Aug 14, 2022 10:26 pm, edited 1 time in total.
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
-
- Posts: 581
- Joined: Mon Sep 07, 2020 8:49 am
Re: Confusion with ULN2803 and IR sensor power
Yea Keith,Keith Baxter wrote: ↑Sun Aug 14, 2022 9:35 pm Hi,
Sorry Kirk. I had a short nap. Just add a not to swap the output state.
I see Joe assisted
KeithCode: Select all
-- Create a new output 1 led1 = hw_output_add("My output led1", true) -- Create a new input 1 hw_input_add("My input 1",function(state) hw_output_set(led1, not state) end) --------------------------------------------------------------- -- Create a new output 2 led2 = hw_output_add("My output led 2", true) -- Create a new input 2 hw_input_add("My input 2",function(state) hw_output_set(led2, not state) end)
He helped out. It's all working now. The more I learn the more I dont know.