Receiving input from Thermistor OR TM36 to control servo

I want to have a servo move back and forth based off of a Thermistor.
Would anyone have the code for that (and maybe the schematic)?

I was able to do it on Arduino, but really no clue with the Maestro.

Thanks in advance.


By the way. This is the code I’m working with.

# Set the servo to 4000, 6000, or 8000 depending on an analog input.
  3 get_position    # get the value of the pot (in my case Thermistor), 0-1023
  dup 300 less_than
    4000   # go to 4000 for values 0-299
    dup 600 less_than
      6000 # go to 6000 for values 300-599
      8000 # go to 8000 for values 600-1023
  5 servo
  drop     # remove the original copy of the thermistor value

I will add more than just 3 steps though.

I wired it ; 1 leg of thermistor to analog input on Maestro. Then other leg of Thermistor I ran to 10K resistor, then to 5V. I’m missing something, like… ground.

I also run the 1 push button sequence for a servo. I need to add a second servo to run under same button. I tried different code settings but kinda lost.

whew never mind on last part of adding a second servo. I have that working. Found it in an old post. Could have sword I searched them all earlier.

With that said, my last main issue is getting 3rd servo to move based on Thermistor temp.

Really could use some help on that.


We do not have any specific code examples for reading from a thermistor with the Maestro, and we do not have any wiring diagrams showing how to connect a thermistor to the Maestro. However, you should be able to find an example schematic showing how to connect a thermistor to any general I/O pin on the Internet. I did a quick Google search and found this example schematic on the Arduino website. You could probably follow that schematic and use one channel on the Maestro as the “Analog In” shown.

Since it sounds like your thermistor circuit is not connected properly to the Maestro, we should focus on getting that working first before working on your script.

I am glad you resolved your problem with adding another servo; thanks for letting us know.

- Amanda

Very good. That went well. getting good readings.

I put it on the input of 5. Will hook the servo up to 4. So now maybe we can dig up some code to make it work.
Thanks Amanda. I was pretty close on how i had it wired last time, but I was using ground and not Positive.

I have the code working on the Arduino side, finally. I can’t run that code on the Maestro can I?

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

const unsigned char temps = A0;    // analog pin used to connect the temp sensor
const unsigned char MAX_VAL = 10;

//Main global varibles
unsigned int val;     // variable to read the value from the analog pin

unsigned int updateAvgtemp()
static int history[MAX_VAL] = {0};
static unsigned char lastHist = 0;
static unsigned char numHist = 0;
unsigned int temp = 0;
unsigned char counter = 0;
unsigned char arcount = 0;
history[lastHist] = analogRead(temps);
if (numHist < MAX_VAL)
arcount = lastHist;
if (lastHist >= MAX_VAL)
    lastHist = 0;
temp = 0;
counter = 0;
    temp += history[arcount];
    if (arcount > MAX_VAL)
        arcount = (MAX_VAL - 1);
}while (counter < numHist);
return (temp / numHist);

void setup()
myservo.attach(9);      // attaches the servo on pin 9 to the servo object

void loop()
val = updateAvgtemp();    // read the value of the temp sensor (value with range of 1024)
val = map(val, 500, 450, 160, 80);  // scale it to use it with the servo (value between 160 and 80)
val = constrain(val, 160, 80);  ///////// Add this line to protect the servo from out-of-range temperature values
myservo.write(val);     // sets the servo position according to the scaled value

delay(125);               // wait 25ms for the servo to move to it's new position and also 100ms until it gets the new value

Thats the code that works. But I don’t want to run a arduino, hence why I bought the Maestro lol

No, you cannot run the Arduino code directly from a Maestro; the Arduino language and Maestro scripting language are different. You probably would need to convert the Arduino code into the Maestro’s scripting language, which could be difficult if you are not familiar with stack-based languages like the Maestro’s scripting language. If you have not already done so, it might be helpful for you to look at “Maestro Script Language Basics” and “Command Reference” sections in its user’s guide.

Also, since the Maestro’s scripting language is similar to FORTH (a stacked-based programming language), I recommend that you search for more in-depth documentation on FORTH to get a better understanding of the process flow of the Maestro’s scripting language before attempting to port over your Arduino code to the Maestro.

- Amanda

Ok, well I’m out of luck. No one i know even heard of FORTH.

I did load the Maestro library from your github into Arduino IDE, but Dangit Scotty I’m a Modder not a Programmer! (see what I did their?)

I’ll do my best to learn what I need to know. When I have more time. If i have to interface an Arduino WITH the Maestro, then I wont bother with the Maestro. I was hoping to develop a kit to mass produce using the Maestro as the core. And may still. Just have to find someone with a clue, which isn’t me at this time.