Results 1 to 14 of 14

Thread: Arduino help please :)

  1. #1
    Senior Member Studio1's Avatar
    Join Date
    Jan 2008
    Location
    In the back of a 50 kW AM transmitter
    Posts
    1,666
    Thanks
    213
    Thanked 285 Times in 185 Posts
    Rep Power
    270
    Reputation
    2406

    Default Arduino help please :)

    I have a fairly simple project I want to construct.
    It's essentially a keypad code lock controlling a relay.
    That's the easy part. Key in the right code and the relay turns on, press the star key and it turns off.
    There are two LED - a red one and a green one to indicate when the relay is on or off.

    Here's where it gets tricky - if I press the hash key at any time, this is what I need to have happen:
    A third LED starts flashing and a timer starts counting down, say from 60 seconds to zero.
    At the end of that time, the relay (if it is on) switches off as does the LED.
    Any thoughts or assistance gratefully appreciated.

    Here's the code I have so far for the basic lock. It's not brilliant but it's a start.



    #include <Keypad.h>

    char* secretCode = "123456";
    int position = 0;

    const byte rows = 4;
    const byte cols = 3;
    char keys[rows][cols] = {
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'}
    };

    byte rowPins[rows] = {4, 5, 6, 7};
    byte colPins[cols] = {1, 2, 3};

    Keypad keypad = Keypad(makeKeymap(keys),
    rowPins, colPins,
    rows, cols);

    int redPin = 8;
    int greenPin = 9;

    void setup()
    {
    pinMode(redPin, OUTPUT);
    pinMode(greenPin, OUTPUT);
    setLocked(true);
    }

    void loop()
    {
    char key = keypad.getKey();
    if (key == '*' || key == '#') {
    position = 0;
    setLocked(true);
    }

    if (key == secretCode[position]) {
    position++;
    }

    if (position == 6) {
    setLocked(false);
    }
    delay(50);
    }

    void setLocked(int locked)
    {
    if (locked) {
    digitalWrite(redPin, HIGH);
    digitalWrite(greenPin, LOW);
    }
    else {
    digitalWrite(redPin, LOW);
    digitalWrite(greenPin, HIGH);
    }
    }
    Last edited by Studio1; 14-09-21 at 07:39 PM.



Look Here ->
  • #2
    Junior Member
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    300
    Thanked 37 Times in 26 Posts
    Rep Power
    151
    Reputation
    660

    Default

    Hi,
    I think that with your starting code, if you type "18273947576" it may open the relay anyway. I guess you can stop that by re-setting the "position" variable here:

    if (key == secretCode[position]) {
    position++;
    }
    else {
    position = 0;
    }

    For the part when the # is pressed, do you need to be able to stop the countdown or as soon as it is pressed there is no way to stop it?

    I have used millis() in the past to read a the current time of a pass in the loop and compare it to a previous pass to toggle outputs. For this comparison, I've used a bigger than or less than in the "if" just in case the time between loops is not exactly 1 second (or whatever) apart.
    If you change this:

    if (key == '*' || key == '#') {
    position = 0;
    setLocked(true);
    }

    to 2 separate lines, one to check for * and another for #, then you can start monitoring the time if # is pressed and leave * as is to reset the state.

    Sorry, I can't write and test the code atm, as my laptop does not have the arduino software anymore, and I'm sure a lot of members can do this for you, If you still struggle, let me know, I have a couple of arduinos in a drawer somewhere. I can always find one and re-install to go through the code with you.

    Good luck

  • The Following User Says Thank You to ammlione For This Useful Post:

    Studio1 (16-09-21)

  • #3
    Senior Member Studio1's Avatar
    Join Date
    Jan 2008
    Location
    In the back of a 50 kW AM transmitter
    Posts
    1,666
    Thanks
    213
    Thanked 285 Times in 185 Posts
    Rep Power
    270
    Reputation
    2406

    Default

    Quote Originally Posted by ammlione View Post
    Hi,
    I think that with your starting code, if you type "18273947576" it may open the relay anyway. I guess you can stop that by re-setting the "position" variable here:

    if (key == secretCode[position]) {
    position++;
    }
    else {
    position = 0;
    }

    For the part when the # is pressed, do you need to be able to stop the countdown or as soon as it is pressed there is no way to stop it?

    I have used millis() in the past to read a the current time of a pass in the loop and compare it to a previous pass to toggle outputs. For this comparison, I've used a bigger than or less than in the "if" just in case the time between loops is not exactly 1 second (or whatever) apart.
    If you change this:

    if (key == '*' || key == '#') {
    position = 0;
    setLocked(true);
    }

    to 2 separate lines, one to check for * and another for #, then you can start monitoring the time if # is pressed and leave * as is to reset the state.

    Sorry, I can't write and test the code atm, as my laptop does not have the arduino software anymore, and I'm sure a lot of members can do this for you, If you still struggle, let me know, I have a couple of arduinos in a drawer somewhere. I can always find one and re-install to go through the code with you.

    Good luck
    Thanks for the response!

    First to answer your questions:

    1) Yes, there is the bug with any sequence of numbers containing the code to be able to open the relay. I did see that, but as I mentioned the code isn't great - it does need a bit of tweaking.

    2) Thanks for the tip on resetting the position variable.

    3) For the part where the # is pressed, I don't need (or want) to stop the countdown.

    I understand about splitting the * and # key checking. That's as far as I can go - I'm still very much in the learning stages of Arduino, so I don't know how to implement the rest of it, as in setting the countdown timer or flashing the LED while the counter is counting.

    I will see what others have for suggestions (I need all the help I can get at the moment) but if you are able to set something up and test it that would be really appreciated!

  • #4
    Junior Member
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    300
    Thanked 37 Times in 26 Posts
    Rep Power
    151
    Reputation
    660

    Default

    I've just asked my daughter about the arduino simulator she uses online (it will save me digging through drawers and installing software )
    Have you used ?
    I'm trying to draw your circuit (probably minus the keypad for now) to see if I can get at least the code additions tested,
    I'll keep you posted

  • The Following User Says Thank You to ammlione For This Useful Post:

    Studio1 (16-09-21)

  • #5
    Junior Member
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    300
    Thanked 37 Times in 26 Posts
    Rep Power
    151
    Reputation
    660

    Default

    Ok, I've drawn part of your circuit (Keypad still not connected) at least the 3 leds are connected.
    You can change the code to try different things as well,

    I've added a function to Countdown for a set time, determined by the variable CountdownTotal set in line 5.
    At the moment the Yellow led will be ON half a second and OFF half a second. The way I did it is very primitive (It can be largely improved) but it is very easy to follow the code.

    Because the keypad is not connected, I've added lines 43 and 44 to call the new function after 1 second (to test it).
    When I get the keypad to work, we can add a function to read the "*" and just call it instead.

    Let me know if you want me to add comments to it.
    Cheers

  • The Following User Says Thank You to ammlione For This Useful Post:

    Studio1 (16-09-21)

  • #6
    Premium Member
    wotnot's Avatar
    Join Date
    Nov 2019
    Posts
    1,654
    Thanks
    686
    Thanked 1,485 Times in 799 Posts
    Rep Power
    672
    Reputation
    29710

    Default

    I find it's always a contradiction to try and help someone 'learn' something like 'arduino programming', by giving them the answers directly -- it's like solving a rubik cube for someone, they don't learn how to do it.

    So I try to be 'helpful' instead - a realistic statement would be, that what you are trying to do here with an arduino, has already been done before by somebodies out there on the 'net, and just to be real here for a moment, your question has little to do with arduino as such, and everything to do with C/C++ coding....and to make matters even more real, all it takes is the correct google search string to find what others have done out there, very similar to what you want to achieve.

    Nanos Gigantium Humeris Insidentes -- standing on the shoulders of giants - or with arduino/software in mind, "discovering truth by building on previous discoveries" ; this is the most useful philosophy to embrace with things arduino IMHO, as aligned with a "don't reinvent the wheel" when it comes coding, use (pre-existing) library routines already written by others. This is especially so when it comes to the arduino IDE and the plethora of support libraries (both hardware and software supports) available for it. Perhaps it depends on the individual, I'm not sure...but with the arduino/maker scene, it doesn't make sense to me to start with 'nothing' and have to write the sketch (code) from scratch, when you can find existing code examples and/or library objects, which you can alter to suit your purpose.

    I have the idea of what you want to do based on your description, and my brain thinks 'store magic number in eeprom, evaluate keypad input, if = magic number do something, else if * key undo something, else if # key do something different' ...but then my mind says 'stop wasting time, google it', and I end up seeing ....and I think that's close sans the LCD stuff which is easily removed, and pretty much everything's done except the hash key handling (which in that sketch is doing the changecode() function) ...but in any event, it's a good (working) example of how to do this. In practice, you'd just remap that function to a different keypress, and add another handler for the # key detection, which would be the function to blink the 3rd LED and de-energize the relay after 60seconds.

    Regarding timers...I recently had a boofle with esp8266 calling millis() inside of loop() for reasons unknown (but I'm not alone), and ended up finding/using the BlockNot library () for timing events. It has a nonblocking LED example you can use to blink the LED. You could stuff that into the # key handler function.... ie; initialize a blocknot 1 second timer in setup(), in a while{} condition, count the blocknot 'ticks' and blink the LED until count reaches 60, then you could use getpinstate(relaypin) to determine if it's on or not, and turn it off if it's on.

    That's just me though, lazy as, determined to use code objects that already exist, and use them like templates, lego blocks, to build what I want. Also, there's some pretty groovy arduino simulator software out there, where you can drag&drop block functions (like in that program flowchart in the link above), assign the values, and it generates the code for you, which you can then simulate and/or upload the the arduino, cool stuff.

    End of the day though, I can get the above code, strip out the LCD stuff, do the above mumbojumbo for hash key handling and paste it here, and it'll likely work, but how useful is that? You should want to do this -- I don't want to 'spoil' your learning curve by proffering a solution based upon others' examples, when you might be more interested in learning this stuff 'from the ground up' kinda thing, and there's absolutely nothing wrong with that at all, that's a good thing, but I'm not a good teacher, I'm more of a doer, hackityhack 8)

  • The Following 2 Users Say Thank You to wotnot For This Useful Post:

    ammlione (16-09-21),Studio1 (16-09-21)

  • #7
    Junior Member
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    300
    Thanked 37 Times in 26 Posts
    Rep Power
    151
    Reputation
    660

    Default

    It took me a bit of a while, but I did it,
    I had to modify the keypad pinout from your original (because I wanted serial comms to report variables) but you can put that back if you need to.


    Let me know if you need any explanations,
    Cheers

  • The Following User Says Thank You to ammlione For This Useful Post:

    Studio1 (16-09-21)

  • #8
    Senior Member Studio1's Avatar
    Join Date
    Jan 2008
    Location
    In the back of a 50 kW AM transmitter
    Posts
    1,666
    Thanks
    213
    Thanked 285 Times in 185 Posts
    Rep Power
    270
    Reputation
    2406

    Thumbs up

    Quote Originally Posted by wotnot View Post
    I find it's always a contradiction to try and help someone 'learn' something like 'arduino programming', by giving them the answers directly -- it's like solving a rubik cube for someone, they don't learn how to do it.

    So I try to be 'helpful' instead - a realistic statement would be, that what you are trying to do here with an arduino, has already been done before by somebodies out there on the 'net, and just to be real here for a moment, your question has little to do with arduino as such, and everything to do with C/C++ coding....and to make matters even more real, all it takes is the correct google search string to find what others have done out there, very similar to what you want to achieve.

    Nanos Gigantium Humeris Insidentes -- standing on the shoulders of giants - or with arduino/software in mind, "discovering truth by building on previous discoveries" ; this is the most useful philosophy to embrace with things arduino IMHO, as aligned with a "don't reinvent the wheel" when it comes coding, use (pre-existing) library routines already written by others. This is especially so when it comes to the arduino IDE and the plethora of support libraries (both hardware and software supports) available for it. Perhaps it depends on the individual, I'm not sure...but with the arduino/maker scene, it doesn't make sense to me to start with 'nothing' and have to write the sketch (code) from scratch, when you can find existing code examples and/or library objects, which you can alter to suit your purpose.

    I have the idea of what you want to do based on your description, and my brain thinks 'store magic number in eeprom, evaluate keypad input, if = magic number do something, else if * key undo something, else if # key do something different' ...but then my mind says 'stop wasting time, google it', and I end up seeing ....and I think that's close sans the LCD stuff which is easily removed, and pretty much everything's done except the hash key handling (which in that sketch is doing the changecode() function) ...but in any event, it's a good (working) example of how to do this. In practice, you'd just remap that function to a different keypress, and add another handler for the # key detection, which would be the function to blink the 3rd LED and de-energize the relay after 60seconds.

    Regarding timers...I recently had a boofle with esp8266 calling millis() inside of loop() for reasons unknown (but I'm not alone), and ended up finding/using the BlockNot library () for timing events. It has a nonblocking LED example you can use to blink the LED. You could stuff that into the # key handler function.... ie; initialize a blocknot 1 second timer in setup(), in a while{} condition, count the blocknot 'ticks' and blink the LED until count reaches 60, then you could use getpinstate(relaypin) to determine if it's on or not, and turn it off if it's on.

    That's just me though, lazy as, determined to use code objects that already exist, and use them like templates, lego blocks, to build what I want. Also, there's some pretty groovy arduino simulator software out there, where you can drag&drop block functions (like in that program flowchart in the link above), assign the values, and it generates the code for you, which you can then simulate and/or upload the the arduino, cool stuff.

    End of the day though, I can get the above code, strip out the LCD stuff, do the above mumbojumbo for hash key handling and paste it here, and it'll likely work, but how useful is that? You should want to do this -- I don't want to 'spoil' your learning curve by proffering a solution based upon others' examples, when you might be more interested in learning this stuff 'from the ground up' kinda thing, and there's absolutely nothing wrong with that at all, that's a good thing, but I'm not a good teacher, I'm more of a doer, hackityhack 8)
    Yes, absolutely I agree with everything you have said and I don't want someone to hand me the solution on a plate.
    I'm looking for ideas on how to achieve a particular function more than anything.
    The sketch I have above is one I have (as you say) already 'borrowed' from someone who has done it before - no sense in reinventing the wheel.
    I'm a hardware guy - give me something broken and I will repair it.
    Software and coding is something I am very new to - so looking at what people are doing is part of the learning process and asking for assistance or ideas on how to achieve what I want is part of that process.
    Yes, I can find examples of timers - but how to integrate that with my application here where the unit is controlling a relay, that's what I need assistance with.
    Years of learning and doing and experimenting has taught me to ask as many questions as I can before I venture into something, because doubtless someone will have been there done that before - so why waste hours and hours trying to achieve something if someone can take a few minutes to point you in the right direction before? That's really my philosophy.
    I do the same for others - they come to me and ask questions that are easily answered if they went to Google and typed it in - but I don't mind giving them a point in the right direction to start with, to save them from spending hours looking for something I know they can find in a few minutes.

    𝘙𝘦𝘨𝘢𝘳𝘥𝘪𝘯𝘨 𝘵𝘪𝘮𝘦𝘳𝘴...𝘐 𝘳𝘦𝘤𝘦𝘯𝘵𝘭𝘺 𝘩𝘢𝘥 𝘢 𝘣𝘰𝘰𝘧𝘭𝘦 𝘸𝘪𝘵𝘩 𝘦𝘴𝘱8266 𝘤𝘢𝘭𝘭𝘪𝘯𝘨 𝘮𝘪𝘭𝘭𝘪𝘴() 𝘪𝘯𝘴𝘪𝘥𝘦 𝘰𝘧 𝘭𝘰𝘰𝘱() 𝘧𝘰𝘳 𝘳𝘦𝘢𝘴𝘰𝘯𝘴 𝘶𝘯𝘬𝘯𝘰𝘸𝘯 (𝘣𝘶𝘵 𝘐'𝘮 𝘯𝘰𝘵 𝘢𝘭𝘰𝘯&#120358, 𝘢𝘯𝘥 𝘦𝘯𝘥𝘦𝘥 𝘶𝘱 𝘧𝘪𝘯𝘥𝘪𝘯𝘨/𝘶𝘴𝘪𝘯𝘨 𝘵𝘩𝘦 𝘉𝘭𝘰𝘤𝘬𝘕𝘰𝘵 𝘭𝘪𝘣𝘳𝘢𝘳𝘺 ([𝘶𝘳𝘭]𝘩𝘵𝘵𝘱𝘴://𝘨𝘪𝘵𝘩𝘶𝘣.𝘤𝘰𝘮/𝘌𝘢𝘴𝘺𝘎0𝘪𝘯𝘨1/𝘉𝘭𝘰𝘤𝘬𝘕𝘰𝘵[/𝘶𝘳𝘭]) 𝘧𝘰𝘳 𝘵𝘪𝘮𝘪𝘯𝘨 𝘦𝘷𝘦𝘯𝘵𝘴. 𝘐𝘵 𝘩𝘢𝘴 𝘢 𝘯𝘰𝘯𝘣𝘭𝘰𝘤𝘬𝘪𝘯𝘨 𝘓𝘌𝘋 𝘦𝘹𝘢𝘮𝘱𝘭𝘦 𝘺𝘰𝘶 𝘤𝘢𝘯 𝘶𝘴𝘦 𝘵𝘰 𝘣𝘭𝘪𝘯𝘬 𝘵𝘩𝘦 𝘓𝘌𝘋. 𝘠𝘰𝘶 𝘤𝘰𝘶𝘭𝘥 𝘴𝘵𝘶𝘧𝘧 𝘵𝘩𝘢𝘵 𝘪𝘯𝘵𝘰 𝘵𝘩𝘦 # 𝘬𝘦𝘺 𝘩𝘢𝘯𝘥𝘭𝘦𝘳 𝘧𝘶𝘯𝘤𝘵𝘪𝘰𝘯.... 𝘪𝘦; 𝘪𝘯𝘪𝘵𝘪𝘢��𝘪𝘻𝘦 𝘢 𝘣𝘭𝘰𝘤𝘬𝘯𝘰𝘵 1 𝘴𝘦𝘤𝘰𝘯𝘥 𝘵𝘪𝘮𝘦𝘳 𝘪𝘯 𝘴𝘦𝘵𝘶𝘱(), 𝘪𝘯 𝘢 𝘸𝘩𝘪𝘭𝘦{} 𝘤𝘰𝘯𝘥𝘪𝘵𝘪𝘰𝘯, 𝘤𝘰𝘶𝘯𝘵 𝘵𝘩𝘦 𝘣𝘭𝘰𝘤𝘬𝘯𝘰𝘵 '𝘵𝘪𝘤𝘬𝘴' 𝘢𝘯𝘥 𝘣𝘭𝘪𝘯𝘬 𝘵𝘩𝘦 𝘓𝘌𝘋 𝘶𝘯𝘵𝘪𝘭 𝘤𝘰𝘶𝘯𝘵 𝘳𝘦𝘢𝘤𝘩𝘦𝘴 60, 𝘵𝘩𝘦𝘯 𝘺𝘰𝘶 𝘤𝘰𝘶𝘭𝘥 𝘶𝘴𝘦 𝘨𝘦𝘵𝘱𝘪𝘯𝘴𝘵𝘢𝘵𝘦(𝘳𝘦𝘭𝘢𝘺𝘱𝘪&#120367 𝘵𝘰 𝘥𝘦𝘵𝘦𝘳𝘮𝘪𝘯𝘦 𝘪𝘧 𝘪𝘵'𝘴 𝘰𝘯 𝘰𝘳 𝘯𝘰𝘵, 𝘢𝘯𝘥 𝘵𝘶𝘳𝘯 𝘪𝘵 𝘰𝘧𝘧 𝘪𝘧 𝘪𝘵'𝘴 𝘰𝘯.𝘗𝘢𝘴𝘵𝘦 𝘺𝘰𝘶𝘳 𝘵𝘦𝘹𝘵 𝘩𝘦𝘳𝘦

    I understand the concept behind most of that, but it's way beyond me at this point. In time, if I do enough of it I will probably get the hang of that.
    Thanks for the link to the keypad project. It's very similar to the project modeled on the sketch I have above, but with the addition of the LCD. I could potentially incorporate that into my project as well.
    I understand what you're saying about taking that code and stripping out bits and adding what I need.
    A useful and insightful post - I appreciate your comments and suggestions.

  • The Following User Says Thank You to Studio1 For This Useful Post:

    wotnot (16-09-21)

  • #9
    Senior Member Studio1's Avatar
    Join Date
    Jan 2008
    Location
    In the back of a 50 kW AM transmitter
    Posts
    1,666
    Thanks
    213
    Thanked 285 Times in 185 Posts
    Rep Power
    270
    Reputation
    2406

    Default

    Quote Originally Posted by ammlione View Post
    It took me a bit of a while, but I did it,
    I had to modify the keypad pinout from your original (because I wanted serial comms to report variables) but you can put that back if you need to.


    Let me know if you need any explanations,
    Cheers
    Thank you!

    I wasn't aware of the wokwi site, that's a really good resource and makes testing so much simpler.
    It works exactly as I need it to.

    I did notice that if I entered '4123456' it also operated - is that a bug?
    Perhaps I need to add this as you mentioned above:

    if (key == secretCode[position]) {
    position++;
    }
    else {
    position = 0;
    }

    I'll have a play with it on the wokwi site and see what I can achieve (I'll probably break it! ha ha)

    Now, in return for your efforts - is there anything I can do for you? Anything you need assistance with?
    I'd buy you a beer but I suspect you're a long, long way from me.

  • #10
    Junior Member
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    300
    Thanked 37 Times in 26 Posts
    Rep Power
    151
    Reputation
    660

    Default

    I'm ok mate, If I can help you I will.
    I don't know where you are, I'm "locked down" in Melbourne waiting for this situation to go away so we can go back to normal again.

    As mentioned above, I don't think I gave you an easy answer, but I showed you where a tool to help.

    There are ways to make your project more efficient in so many ways it is not funny, but I gather that you are only trying to learn a bit of programming.
    BTW, I'm not a programmer, I'm an electronics tech that plays with hardware most of the time as well, just needed to learn programming to fix stuff like you.

    If you get stuck again, you can save your project in Wokwi and share the link so anyone can help you again.

    Good luck

  • #11
    Premium Member
    wotnot's Avatar
    Join Date
    Nov 2019
    Posts
    1,654
    Thanks
    686
    Thanked 1,485 Times in 799 Posts
    Rep Power
    672
    Reputation
    29710

    Default

    Quote Originally Posted by Studio1 View Post
    Yes, absolutely I agree with everything you have said and I don't want someone to hand me the solution on a plate.
    I'm looking for ideas on how to achieve a particular function more than anything.

    /snip/

    Thanks for the link to the keypad project. It's very similar to the project modeled on the sketch I have above, but with the addition of the LCD. I could potentially incorporate that into my project as well.
    I understand what you're saying about taking that code and stripping out bits and adding what I need.
    A useful and insightful post - I appreciate your comments and suggestions.
    All good mate, I'm glad you appreciate the view.... a lot of my history in these regards, was with industrial process control, and the nightmare lives on in my mind....ie; you talking about having a green & red LED to indicate if the relay is on or off, a little voice in the back of my head says you take the LED power from the switched outputs of the relay because it's a better telltale than just knowing whether the relay coil is being energized =)

  • #12
    Senior Member Studio1's Avatar
    Join Date
    Jan 2008
    Location
    In the back of a 50 kW AM transmitter
    Posts
    1,666
    Thanks
    213
    Thanked 285 Times in 185 Posts
    Rep Power
    270
    Reputation
    2406

    Default

    Quote Originally Posted by ammlione View Post
    I'm ok mate, If I can help you I will.
    I don't know where you are, I'm "locked down" in Melbourne waiting for this situation to go away so we can go back to normal again.

    As mentioned above, I don't think I gave you an easy answer, but I showed you where a tool to help.

    There are ways to make your project more efficient in so many ways it is not funny, but I gather that you are only trying to learn a bit of programming.
    BTW, I'm not a programmer, I'm an electronics tech that plays with hardware most of the time as well, just needed to learn programming to fix stuff like you.

    If you get stuck again, you can save your project in Wokwi and share the link so anyone can help you again.

    Good luck
    Melbourne, I know it well. I had family there in Hoppers Crossing. You'll know where that is.
    I'm over the ditch in windy Wellington, NZ.
    We've just come out of a 3 week Level 4 lockdown - Auckland is still at Level 4. We're at Level 2 which allows a little more freedom.
    Thanks again for your help. Like I said to wotnot, I'm not expecting a complete solution on a plate - just pointers to set me in the right direction.
    You will know all too well how we struggle with something for a long time, then someone comes along and says "just do this" and it's sorted in a matter of seconds!
    It's the curse of the electronics technician.
    When I get a little more time I am going to do more with the wokwi and see how I can improve the design.
    One thing I noticed is if the relay is off (red LED on) and I press the # key it starts the timer so I will find a way to inhibit that unless the relay is on.
    It's not important, it doesn't matter if the timer is started when the relay is off - but it will just make it a bit better.

    What area of electronics are you working in?

  • #13
    Senior Member Studio1's Avatar
    Join Date
    Jan 2008
    Location
    In the back of a 50 kW AM transmitter
    Posts
    1,666
    Thanks
    213
    Thanked 285 Times in 185 Posts
    Rep Power
    270
    Reputation
    2406

    Default

    Quote Originally Posted by wotnot View Post
    All good mate, I'm glad you appreciate the view.... a lot of my history in these regards, was with industrial process control, and the nightmare lives on in my mind....ie; you talking about having a green & red LED to indicate if the relay is on or off, a little voice in the back of my head says you take the LED power from the switched outputs of the relay because it's a better telltale than just knowing whether the relay coil is being energized =)
    As I was looking at the design last night, that concept came to me as well. Use a pair of contacts on the relay to show when it's on or off.
    It's actually a better way of doing it, as it gives confirmation the relay has actually switched.
    When I thought about this project, having a red and green LED wasn't actually part of the plan - but they were present on the sketch that I 'borrowed' so I just left them there as they could be used in this application.
    If I remove them off the layout then I can also remove the code which simplifies the operation.

  • #14
    Junior Member
    Join Date
    Jul 2010
    Posts
    63
    Thanks
    300
    Thanked 37 Times in 26 Posts
    Rep Power
    151
    Reputation
    660

    Default

    Quote Originally Posted by Studio1 View Post
    Melbourne, I know it well. I had family there in Hoppers Crossing. You'll know where that is.
    I'm over the ditch in windy Wellington, NZ.
    We've just come out of a 3 week Level 4 lockdown - Auckland is still at Level 4. We're at Level 2 which allows a little more freedom.
    Thanks again for your help. Like I said to wotnot, I'm not expecting a complete solution on a plate - just pointers to set me in the right direction.
    You will know all too well how we struggle with something for a long time, then someone comes along and says "just do this" and it's sorted in a matter of seconds!
    It's the curse of the electronics technician.
    When I get a little more time I am going to do more with the wokwi and see how I can improve the design.
    One thing I noticed is if the relay is off (red LED on) and I press the # key it starts the timer so I will find a way to inhibit that unless the relay is on.
    It's not important, it doesn't matter if the timer is started when the relay is off - but it will just make it a bit better.

    What area of electronics are you working in?
    I'm north of Melbourne (not in North Melbourne ), and yes I know where Hoppers is, I used to pass that on my way to Avalon Airport when I used to work around there.

    You can add other conditions to line 46 (when we check if the "#" is pressed) and you can "join" them with AND, OR as you like

    Currently I'm mainly designing PCBs for Automotive industry as the main thing, but helping with other tidbits as well at the same company. I'm happy that I don't have a repetitive job and it is very challenging to keep me from getting bored.

  • Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •