Odpověď na: Max6675
Úvodní stránka › Fórum › Vaše projekty › Arduino › Max6675 › Odpověď na: Max6675
12.2.2017 v 16:47
#10446
rehot79
Účastník
Tak prikladám znova s úpravami kode.
//M.jakab29@gmail.com
//Vsetky kniznice nacitane v arduinoIDE spravca kniznic /////
#include "max6675.h"
//Servo
#include <Servo.h>
Servo myservo;
//Oled ///////////////////
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
/////////////
//Definicia pin
int thermoSO = 6;
int thermoCS = 5;
int thermoSCK = 4;
MAX6675 thermocouple(thermoSCK, thermoCS, thermoSO);
int vccPin = 3; //Napajanie + pre max6675 modul z digitalneho pinu
int gndPin = 2; //Napajanie - pre max6675 modul z digitalneho pinu
int val;
int poloha;
void setup() {
// definicia napajacich pinou
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
////definicia servo pinu
myservo.attach(9);
//////////////////////Oled////////////
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
// init done
// Vycisti logo
display.clearDisplay();
//uvod email
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(10,0);
display.println("M.Jakab29@Gmail.com");
display.display();
delay(5000);
display.clearDisplay();
}
void loop() {
// Nacitanie teploty
val = thermocouple.readCelsius()-2;
// text display text
display.drawLine(0, 13, 0, display.height()-1, WHITE);
display.drawLine(300, 32, 0, display.height()-1, WHITE);
display.drawLine(300, 13, 0, display.height()-20, WHITE);
display.drawLine(127, 13, 127, display.height() -1, WHITE);
display.drawLine(62, 13, 62, display.height() -1, WHITE);
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(3,2);
display.println("Teplota Poloha%");
display.setTextSize(2);
display.setCursor(10,16);
display.println(val);
val = map(val, 0, 600, 0, 180);
myservo.write(val);
poloha = myservo.read();
poloha= map(poloha, 0, 180, 0, 100);
display.setTextSize(2);
display.setCursor(70,16);
display.println(poloha);
display.display();
delay(5000);
display.clearDisplay();
}
Tu už vypisuje aj polohu serva na Display .