Potentiometer to servo ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
uxhamby
Normal user
Posts: 132
Joined: 29 Dec 2016, 18:13
Location: Toronto Canada

Potentiometer to servo ?

#1 Post by uxhamby » 09 Feb 2017, 20:21

I'm playing with espeasy on an esp3 module.

I have an Arduino Nano connected and working as a ProMiniExtender (PME) . I am successfully reading a potentiometer value via the PME. I use the formula section of the device page to derive a 'Percent' of full rotation value from the returned raw 0 - 1023 adc value,

I also have a servo attached to GPIO14 of the same device and can alter its position with commands at the browser url line and at the espeasy 'tools' page for the device in question.

I'd like to have the Percent of full rotation value of the pot reflected in the servo's position as a perccent of 180 degrees. I have checked around the wiki and the forum but am not seeing the info I need. I surmise I need a rule to do the work but my attempts as yet haven't worked.

on LegoPME#Percent do
Servo,1,14,%LegoPME#Percent%
endon

Either I am asking the impossible or its a simple syntax issue.

Thoughts or advice please.

Thanks,

Brian H.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Potentiometer to servo ?

#2 Post by toffel969 » 10 Feb 2017, 10:02

uxhamby wrote:I'm playing with espeasy on an esp3 module.

I have an Arduino Nano connected and working as a ProMiniExtender (PME) . I am successfully reading a potentiometer value via the PME. I use the formula section of the device page to derive a 'Percent' of full rotation value from the returned raw 0 - 1023 adc value,

I also have a servo attached to GPIO14 of the same device and can alter its position with commands at the browser url line and at the espeasy 'tools' page for the device in question.

I'd like to have the Percent of full rotation value of the pot reflected in the servo's position as a perccent of 180 degrees. I have checked around the wiki and the forum but am not seeing the info I need. I surmise I need a rule to do the work but my attempts as yet haven't worked.

on LegoPME#Percent do
Servo,1,14,%LegoPME#Percent%
endon

Either I am asking the impossible or its a simple syntax issue.

Thoughts or advice please.

Thanks,

Brian H.

Try

Code: Select all

Servo,1,14,[LegoPME#Percent]
Check the PIR example from the rules tutorial:
http://www.letscontrolit.com/wiki/index ... rial_Rules

Code: Select all

On PIR#Switch do
  if [LDR#Light]<500
    gpio,16,[PIR#Switch]
  endif
endon
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
uxhamby
Normal user
Posts: 132
Joined: 29 Dec 2016, 18:13
Location: Toronto Canada

Re: Potentiometer to servo ?

#3 Post by uxhamby » 10 Feb 2017, 23:08

Yes, that seems to do it. I had tried brackets but not the square ones. Made all the difference. Thanks!

Brian H.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Potentiometer to servo ?

#4 Post by toffel969 » 11 Feb 2017, 00:29

uxhamby wrote:Yes, that seems to do it. I had tried brackets but not the square ones. Made all the difference. Thanks!

Brian H.
Pleasure
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 99 guests