Entschuldigt, der Schaltplan verwendet ein anderes LCD, denn meines. Habe das einfach mittels Autorouting von Fritzing verbinden lassen. Ich verwende den ArduinoTFT, welcher nach dem Tutorial angeschlossen, (http://arduino.cc/en/Guide/TFTtoBoards), einwandfrei funktioniert..
Nochmals zum Sketch; Die Anzeige der Temperatur über den LCD funktioniert schoneinmal, nun wollte ich als ersten Versuch den Transistor erstmal über einen einfachen Knopf betätigen. Sprich wenn der Knopf gedrückt ist, sollte der Heizwiederstand ("Hot-End" im Schaltplan) anspringen. Die Basis des Transis ist über einen 680? Widerstand mit digitalPin11 verbunden, der Knopf (entsprechend des Button-Tutorials) an digitalPin 2 angeschlossen..
Könnte mir vielleicht jemand auf die Sprünge helfen, weshalb im folgenden Sketch, bei drücken des Button`s nun der Heizwiderstand partout nicht anspringen will..
/*
Thermostat
NTC 100kohm, 160x128pixel LCD-Display, 12V/20W Heizwiederstand
Unter Verwendung verschiedener Sketches
LCD-Anschlüsse;
*LCD MISO-PIN an Arduino digital-Pin50
*LCD SCK-PIN an Arduino digital-Pin52
*LCD MOSI-PIN an Arduino digital-Pin51
*LCD CS-PIN an Arduino PMW-Pin10
*LCD D/C-PIN an Arduino PMW-Pin9
*LCD RESET-PIN an Arduino PMW-Pin8
*LCD BL-PIN an +5V
* Arduino digital pin 8 ist der Schalt-Ausgang für den Heizer
* Arduino digital pin 9 ist der Schalt-Ausgang für den Alarm
*/
// which analog pin to connect
#define THERMISTORPIN A0
// resistance at 25 degrees C
#define THERMISTORNOMINAL 100000
// temp. for nominal resistance (almost always 25 C)
#define TEMPERATURENOMINAL 25
// how many samples to take and average, more takes longer
// but is more 'smooth'
#define NUMSAMPLES 10
// The beta coefficient of the thermistor (usually 3000-4000)
#define BCOEFFICIENT 4092
// the value of the 'other' resistor
#define SERIESRESISTOR 1000
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Mega
#define cs 10
#define dc 9
#define rst 8
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
const int buttonPin = 2; // the number of the pushbutton pin
const int relayPin = 11; // the number of the LED pin
int samples[NUMSAMPLES];
int buttonState = 0; // variable for reading the pushbutton status
void setup(void) {
Serial.begin(9600);
analogReference(EXTERNAL);
pinMode(relayPin, OUTPUT); // declare relay wire as output
pinMode(buttonPin, INPUT); // declare pushbutton as input
TFTscreen.begin(); // Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.background(0, 0, 0); // clear the screen with a black background
// write the static text to the screen
TFTscreen.stroke(255,255,255); // set the font color to white
TFTscreen.setTextSize(2); // set the font size
TFTscreen.text("Sensor Value :\n ",0,0); // write the text to the top left corner of the screen
TFTscreen.setTextSize(5); // ste the font size very large for the loop
}
void loop(void) {
buttonState = digitalRead(buttonPin); // read the state of the pushbutton value
// check if the pushbutton is pressed.
if (buttonState == HIGH) { // if it is, the buttonState is HIGH
digitalWrite(relayPin, HIGH); } // turn LED on
else {
digitalWrite(relayPin, LOW); } // turn LED off:
uint8_t i;
float average;
// take N samples in a row, with a slight delay
for (i=0; i< NUMSAMPLES; i++) {
samples[i] = analogRead(THERMISTORPIN);
delay(10);
}
// average all the samples out
average = 0;
for (i=0; i< NUMSAMPLES; i++) {
average += samples[i];
}
average /= NUMSAMPLES;
Serial.print("Average analog reading ");
Serial.println(average);
// convert the value to resistance
average = 1023 / average - 1;
average = SERIESRESISTOR / average;
Serial.print("Thermistor resistance ");
Serial.println(average);
float steinhart;
steinhart = average / THERMISTORNOMINAL; // (R/Ro)
steinhart = log(steinhart); // ln(R/Ro)
steinhart /= BCOEFFICIENT; // 1/B * ln(R/Ro)
steinhart += 1.0 / (TEMPERATURENOMINAL + 273.15); // + (1/To)
steinhart = 1.0 / steinhart; // Invert
steinhart -= 273.15; // convert to C
Serial.print("Temperature ");
Serial.print(steinhart);
Serial.println(" *C");
char valueText[8]; //enough space for "-XXX.XX" + 1 for the null terminator
dtostrf( steinhart, 1, 2, valueText ); // convert float to char array (with 2 digits precision)
TFTscreen.text( valueText, 0, 20 );
// set the font color
TFTscreen.stroke(255,255,255);
// print the sensor value
TFTscreen.text(valueText, 0, 20);
// wait for a moment
delay(1000);
// erase the text you just wrote
TFTscreen.stroke(0,0,0);
TFTscreen.text(valueText, 0, 20);
delay(100);
}