IR Temperature Sensor to move Servos

Hey guys,

I just bought an IR temperature Sensor. Got it working to read the temperature. However, is there a way to set it up so that i could map the temperature and move servos depending on it? The problem i had was the IR temperature Sensor is read through the digitalread instead of analogread. Is there any way i could change that or read data from there to move servos?

1st code would be to read the temperature and 2nd would be the servos that responds to light sensors.

/*
 * File:    readTemperature.ino
 * Author:  Andy Gelme (@geekscape) & Angus Gratton (angus at freetronics. com)
 * License: GPLv3
 *
 * For more information see www.freetronics.com/irtemp
 *
 */

#include "IRTemp.h"

static const byte PIN_DATA    = 2; // Choose any pins you like for these
static const byte PIN_CLOCK   = 3;
static const byte PIN_ACQUIRE = 4;

static const TempUnit SCALE=CELSIUS;  // Options are CELSIUS, FAHRENHEIT

IRTemp irTemp(PIN_ACQUIRE, PIN_CLOCK, PIN_DATA);

void setup(void) {
  Serial.begin(9600);
  Serial.println("IRTemp example");
  Serial.println("~~~~~~~~~~~~~~");
}

void loop(void) {
  float irTemperature = irTemp.getIRTemperature(SCALE);
  printTemperature("IR", irTemperature);

  float ambientTemperature = irTemp.getAmbientTemperature(SCALE);
  printTemperature("Ambient", ambientTemperature);

  delay(1000);
}

void printTemperature(
  char  *type,
  float  temperature) {

  Serial.print(type);
  Serial.print(" temperature: ");

  if (isnan(temperature)) {
    Serial.println("Failed");
  }
  else {
    Serial.print(temperature);
    Serial.println(SCALE == FAHRENHEIT  ?  " F"  :  " C");
  }
}
#include <Servo.h> 
Servo MyServoa, MyServob, MyServoc; 

void setup() {
Serial.begin(115200); //start the serial connection
MyServoa.attach(9);
MyServob.attach(11);
MyServoc.attach(6);
}
void loop() {
int sensorValue = analogRead(0);
Serial.println(sensorValue);
sensorValue = map(sensorValue,200,800,0,60);
MyServoa.write(sensorValue);
MyServob.write(sensorValue);
MyServoc.write(sensorValue);//set the servo position to remapped value
}

Cheers,
Kelvin Karel

Something like:

[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]void loop() {[/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace][/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]float sensorValue = [/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]irTemp.getIRTemperature(SCALE);[/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace][/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]Serial.println(sensorValue);[/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace][/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]int servoValue = map(sensorValue, 0.0, 100.0, 0, 60);[/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace][/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]MyServoa.write(servoValue);[/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace][/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]MyServob.write(servoValue);[/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace][/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]MyServoc.write(servoValue); //set the servo positions to remapped value[/font][/color][color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace][/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]}[/font][/color]
[color=#222222][font='DejaVu Sans Mono', Monaco, Consolas, monospace]

is that some sort or sarcastic reply or has something gone wrong?

is that some sort or sarcastic reply or has something gone wrong?

hey guys, is there a way to map the IR temperature to move servos? Cheers, Kelvin Karel

Considering a temp sensor gives you higher output for higher temperatures, yes.

kelvinkl08: is there a way to map the IR temperature to move servos?

To map what from where?

This might be a starting point: https://learn.adafruit.com/adafruit-tmp007-sensor-breakout/overview

Hi,I'd say something wrong, occasionally I get to choose between TEXT or GRAPHIC based pages for some reason when I jump back to main menu.

Tom.....Just as confused as the rest.... :)