I was trying to hack the lmremote sketch to get it to change the servo based on the NADC value read from the thermistor. I just wanted to see if I could then heat/cool the thermistor and see the servo move. Well, it didn't go well. In fact it didn't work. Could you take a quick look and see what is happening? I think the problem is that there is no delay after the myservo.write, but I'm not positive.
I put the code into the transmitTemp function thinking that when we send the temp to the HM that would be a good time to update the servo position. I used map to scale the NADC value to a position between 0 and 79. That piece works as I am able to write it out to the serial port.
Here is the snippet of code:
static void transmitTemp(unsigned char pin)
{
unsigned char outbuf[4];
unsigned char nodeId = _rfNodeBaseId + pin;
unsigned int val = _previousReads[pin];
val <<= (12 - (10 + TEMP_OVERSAMPLE_BITS));
outbuf[0] = 0x90 | ((nodeId & 0x3f) >> 2);
outbuf[1] = ((nodeId & 0x3f) << 6) | _isRecent | (val >> 8);
outbuf[2] = (val & 0xff);
outbuf[3] = HYGRO_LMREMOTE_KEY | _isBattLow;
//Serial.println(outbuf[3], HEX);
// Don't check for air to be clear, we just woke from sleep and it will be milliseconds before
// the RFM chip is actually up and running
rf12_sendStart(outbuf, sizeof(outbuf));
rf12_sendWait(SLEEPMODE_TX);
pos = map(val, 1000, 2100, 0, 179);
myservo.write(pos);
}
I have in setup:
myservo.attach(6);
So I'm using PD6 to control the servo. 2 and 4 were already used so I thought 6 made sense
any ideas?
dave