hello..hai everyone.i am new here and new to arduino..nice to meet all of you .guys,i need you guys help. actually i am using thermocouple MAX6675 in my project connect with arduino mega 2560. i want to measure the substance in my project that have a temperature around 150-200 degree celcius.. when my thermocouple detect the temperature,my motor will start to move. i am using DC motor and i just control the direction of motor.i don't control the PWM of my motor..that is the reason i just connect my PWM to the digital output.and i already test the code for the motor..and it already works.so now i just want to insert my function of motor when my thermocouple detect the temperature around 150 to 200..thats all.. but the problem is, i don't know how i want to fix this code so that at 150 to 200 celcius my motor will start to move..can you guys help me??i am totally do not know how the spi works actually and how the code works to get the temperature..i am really new in this kind of things and need to learn something from all of you. i am trying search and do some homeworks but still i do not understand.. i feel disappointed to myself.
// this example is public domain. enjoy!
// www.ladyada.net/learn/sensors/thermocouple
#include <max6675.h>
#include <LiquidCrystal.h>
#include <Wire.h>
int thermoDO = 29; //so
int thermoCS = 30; //cs
int thermoCLK = 28; //sck
int PWM1 = 34; // speed of motor
int DIR= 4; // Direction (cw/ccw) of motor
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
LiquidCrystal lcd(22,23,27,26,25,24);
// make a cute degree symbol
uint8_t degree[8] = {140,146,146,140,128,128,128,128};
void setup() {
Serial.begin(9600);
// use Arduino pins
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
pinMode(PWM1, OUTPUT); //for motor
pinMode(DIR, OUTPUT); //for motor
lcd.begin(16, 2);
lcd.createChar(0, degree);
// wait for MAX chip to stabilize
delay(500
);
}
void loop() {
// basic readout test, just print the current temp
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("MAX6675 test");
// go to line #1
lcd.setCursor(0,1);
lcd.print(thermocouple.readCelsius());
#if ARDUINO >= 100
lcd.write((byte)0);
#else
lcd.print(0, BYTE);
#endif
lcd.print("C ");
lcd.print(thermocouple.readFahrenheit());
#if ARDUINO >= 100
lcd.write((byte)0);
#else
lcd.print(0, BYTE);
#endif
lcd.print('F');
delay(1000);
}
void motor()
{
digitalWrite(DIR,LOW);
digitalWrite(PWM1,HIGH);
delay(3000);
digitalWrite(DIR,HIGH);
digitalWrite(PWM1,HIGH);
delay(3000);
}
thanks to ladyada i get this code.but to modify this, i hope you guys can help me.. thanks in advance..