George Kartsonas
Published

MAX32620 FHTR Heat Control Unit

A simple step-bystep procedure to control anything in your home using the MAX32620 FTHR.

BeginnerProtip1 hour953

Things used in this project

Hardware components

MAX32630FTHR
Maxim Integrated MAX32630FTHR
×1
Relay (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE
Processing

Story

Read more

Code

Arduino Relay Code

Arduino
void setup()
{
pinMode(12, OUTPUT);
Serial.begin(9600);
while (!Serial);
Serial.println("Input 1 to Turn LED on and 2 to off");
}

void loop() {
if (Serial.available())
{
int state = Serial.parseInt();
if (state == 1)
{
digitalWrite(12, HIGH);
Serial.println("Command completed LED turned ON");
}
if (state == 2)
{
digitalWrite(12, LOW);
Serial.println("Command completed LED turned OFF");
}
}
}

Processing GUI Code

JavaScript
import controlP5.*; //import ControlP5 library
import processing.serial.*;

Serial port;

ControlP5 cp5; //create ControlP5 object
PFont font;

void setup(){ //same as arduino program

  size(300, 450);    //window size, (width, height)
  
  printArray(Serial.list());   //prints all available serial ports
  
  port = new Serial(this, "COM19", 9600);  //i have connected arduino to co19, it would be different in linux and mac os
  
  //lets add buton to empty window
  
  cp5 = new ControlP5(this);
  font = createFont("calibri light bold", 26);    // custom fonts for buttons and title
  
  cp5.addButton("red")     //"red" is the name of button
    .setPosition(100, 50)  //x and y coordinates of upper left corner of button
    .setSize(120, 70)      //(width, height)
    .setFont(font)
  ;   
  
  cp5.addButton("alloff")     //"alloff" is the name of button
    .setPosition(100, 250)  //x and y coordinates of upper left corner of button
    .setSize(120, 70)      //(width, height)
    .setFont(font)
  ;
}

void draw(){  //same as loop in arduino

  background(150, 0 , 150); // background color of window (r, g, b) or (0 to 255)
  
  //lets give title to our window
  fill(0, 255, 0);               //text color (r, g, b)
  textFont(font);
  text("LIGHT CONTROL", 80, 30);  // ("text", x coordinate, y coordinat)
}

//lets add some functions to our buttons
//so whe you press any button, it sends perticular char over serial port

void red(){
  port.write('1');
}

void alloff(){
  port.write('2');
}

Credits

George Kartsonas

George Kartsonas

19 projects • 46 followers

Comments