0
\$\begingroup\$

I want to make potentiometer that goes to 0 to 100% ONLY if I start to open it from 50%.
That means, if I open it to 51%, it will report as 2%. if I open it at 75%, it will report as 50%.

In Arduino, I can make it like this

int val = analogRead(0);
if (val < 50) 
{
   val = 0;   
} 
val = map(analogRead(A0,51,100,0,100);
//okay that's stupid coding for sure. 

How can I do this without arduino?

EDIT : I want to do it WITHOUT microcontroller. EDIT 2 : I want to do it as simple as possible, and if possible without using any IC.

\$\endgroup\$
9
  • \$\begingroup\$ Pick another micro controller? What do you mean by "report"? a binary number, an analog voltage, a synthesized voice? \$\endgroup\$
    – John D
    Commented Aug 5, 2017 at 18:40
  • \$\begingroup\$ you realize that analogRead is a voltage reading right? It converts it to a decimal value that represents a voltage range between 0 and 5 volts. \$\endgroup\$
    – user103380
    Commented Aug 5, 2017 at 19:26
  • 2
    \$\begingroup\$ What do you mean by "without arduino"? Do you mean without the Arduino library, or without using a microcontroller at all? \$\endgroup\$
    – user39382
    Commented Aug 5, 2017 at 19:32
  • \$\begingroup\$ There is no general way to make that part act as you suggest. There are some situations where it is possible easily and others in which it is not practical (depending on the way it is used in the circuit). You could buy a centre-tapped pot of double the resistance and use the tap as one side of the element. \$\endgroup\$ Commented Aug 5, 2017 at 19:38
  • 1
    \$\begingroup\$ You want to do this with a analogue circuit? It is possible to design a OP Amp circuit that solves the challange. \$\endgroup\$
    – MatsK
    Commented Aug 6, 2017 at 10:07

2 Answers 2

1
\$\begingroup\$

If you look at map()'s documentation you will see that it's a simple scaling function:

long map(long x, long in_min, long in_max, long out_min, long out_max)
{
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

If for whatever reason you don't have access to the Arduino standard library, you can just copy this function into your code and use it.

\$\endgroup\$
1
  • \$\begingroup\$ I didnt realize that. Thanks! But I still want to avoid microcontroller. \$\endgroup\$ Commented Aug 6, 2017 at 9:50
1
\$\begingroup\$

This should work.

int val = analogRead(0);
if (val < 50) 
{
  output = 0;   
} else
{
  output = ((val - 50)*2);
}
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.