thermocouple MAX6675 interface

Hi,

I am new on Arduino programming. As my first project, I would like to read the 16-bit number that directly measured from the MAX6675 thermocouple and then convert the number to a PWM output from the Arduino. Could anyone help me with this?

Is this your second post on the same topic,, using a slightly different alias?

Do not waste our time by cross posting.

It is easy but I do not want to wast my time on cross posting! This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

Library - https://github.com/enjoyneering/MAX6675

Code for Uno, Nano, Mini (MOSI-11, MISO-12, SCLK-13, CS-up to you, except pin no.10)

#include <SPI.h>
#include <MAX6675.h> //https://github.com/enjoyneering/MAX6675

uint16_t temperature = 0;

MAX6675 myMAX6675(4); //cs - chip select, pin 4


void setup()
{
  Serial.begin(115200);
  Serial.println();

  myMAX6675.begin(); //start MAX6675

  while (myMAX6675.getChipID() != MAX6675_ID)
  {
    Serial.println(F("MAX6675 error"));
    delay(5000);
  }

  Serial.println(F("MAX6675 OK"));

  if (myMAX6675.detectThermocouple() == true)
  {
    Serial.println(F("K-Thermocouple is connected to MAX6675 terminals 'T+' & 'T-'"));
  }
  else
  {
     Serial.println(F("K-Thermocouple is broken, unplugged or 'T-' terminal is not grounded"));
  }

  pinMode(5, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop()
{
  temperature = myMAX6675.getTemperature();

  if (temperature != MAX6675_ERROR)
  {
     Serial.println(temperature);

     temperature = map(temperature, 0, 1024, 0, 255); //0°C...+1024°C to 0..255 PWM
     analogWrite(5, temperature);

     digitalWrite(13, LOW);
  }
  else
  {
     Serial.println(F("K-Thermocouple is broken, unplugged or 'T-' terminal is not grounded"));

     analogWrite(5, 0);
     digitalWrite(13, HIGH);
  }
  
  delay(1000);
}