How can I change a variable value 'on board'...


  • Mod

    I finally have all that I need to move on with my boards.

    One of my first desired sensors is my waterflow project to enable/disable a warm water pump.

    However, there is one very important variable that I need to fine-tune over time.
    Instead of having to attach my laptop each time I would like to do that 'on-board'.

    I was thinking about adding a double dip switch.

    switch 1 to enable a led to blink to help me when fine-tuning.
    switch 2 to enable changing the value.

    Question: what do I need?
    Is it a pot meter?
    If so how do I program it to change the value and what resistance do I need?

    I hope someone can help me to figure this out πŸ™‚


  • Mod

    OK, part of this was too simple to even think of asking for an answer.

    The pot meter is implemented and it works as expected.
    The led is added with the dip switch for on/off (save current).

    Now a more important question:
    Will checking the value of the pot meter in the loop use (much) current?

    How would I reliably measure this?


  • Admin

    @marceltrapman said:

    Will checking the value of the pot meter in the loop use (much) current?

    If you have a multimeter you should be able to measure it.



  • Or calculate: I=U/R
    Take care about how the pot is connected. If it is possible to turn it to zero it will become a shorted output pin!
    Found on the internet: "The microcontroller datasheet specifies an absolute maximum per-pin current of 40mA. With a typical internal resistance of only 25 ohms per pin, a dead short to ground can allow as much as 200mA of current to flow, more than enough to destroy the microcontroller output".


  • Mod

    @C4Vette The one I am testing with can not be turned to 0 as far as I have seen but I will certainly check this with the ones for production.
    Can I simply add a resistor or do I have to do something else?



  • @marceltrapman
    I would use a 10K pot.meter and connect the outer pins to +5 and gnd. Connect the pin in the middle to an analogue pin and use:
    val = analogRead(potPin) which will give you a value between 0 and 1023.


  • Mod

    @C4Vette Thank I will order one πŸ™‚


Log in to reply
 

Suggested Topics

  • 4
  • 9
  • 4
  • 2
  • 20
  • 17

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts