works on uno, doesn't work on due

as the title reads, the same program wont run in due. can’t raise or lower the temperature setting.

#include <LiquidCrystal.h>// include the library code
int tempPin = A0; // make variables// thermistor is at A0
int dilatacion=A1;
int mosfet =9; // led is at pin

float temp; // make a variable called temp
int settemp=50; // make a variable called settemp
int upTemp = 7; // switch up is at pin 7
int downTemp = 6; // switch down is at pin 6
int confirmar =9;
//int led =13;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // lcd is at 12,11,5,4,3,2

void setup() {
//pinMode (mosfet,1); // make led or pin13 an output
//pinMode (confirmar,0);
//pinMode (led,1);
Serial.begin (9600);
lcd.begin(16, 2);

lcd.clear(); // clear the lcd


void loop() {
int tvalue = analogRead(tempPin); // make tvalue what ever we read on the tempPin
float temp = (tvalue / 6.388888888889); // the math / conversion to temp
lcd.setCursor (0,1); // set the cursor to 0,0
lcd.print (temp); // Print the current temp in f
lcd.print (‘C’);
Serial.println (temp); // print the temp it the serial monitor

delay (150); // wait for the lcd to refresh every 250 milliseconds

if (digitalRead(upTemp)== 1 ){
delay (50);
settemp ++ ; // add one to the settemp, the settemp is the ideal temperature for you

else{// other wise do nothing


if (digitalRead (downTemp) == 1){// if we detect a 1 on the other switch pin
delay (50);
displayTemp=settemp --;// subtract one fromm the settemp

else {// else, do nothing


if (temp < settemp ) {
// if the temperature exceeds your chosen settemp

analogWrite (mosfet, 10); // turn on the led
digitalWrite (10,HIGH);


else{ // if that doesn’t happen, then turn the led off

digitalWrite (mosfet,0);

lcd.setCursor (0,0); // set the cursor to 0,1
lcd.print (“T final: “); // Print set to and your ideal temperature in f
lcd.print (displayTemp);
lcd.print (“C”);
Serial.println(settemp); // Print the settemp in the serial montior
Serial.println (temp); // print the temp it the serial monitor
delay (250); // wait 250 milliseconds



Please use [ code ] tags. The forum software eats some of you code if you don't.

Please delete anything that is commented out. It is difficult to see what your program really does with old references to LEDs and MOSFETs.


Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom.. :)

where is the pinMode settings for the INPUT and OUTPUT pins?

Hi, Your code would not compile until a variable was declared . As sarouje has pointed out you have not setup INPUT and OUTPUT.

Also can do a TOOLS, AUTO-FORMAT please, to help with indents.

Thanks..... Tom........ :)

the same program wont run in due.

If it compiled, linked, and uploaded, the DUE CAN run the code.

Whether doing so produces the results you expect, or not, is a different story. The code does SOMETHING which you did not bother to include. You expect it to do something, which you did not bother to include. All we can surmise, from what you posted incorrectly, is that the two somethings are not the same thing. That is nowhere near enough information to help you.