Temperature TRANSISTOR + LED. HELP (CODE)?

Hello guys!

I have just start a new project. I want to register my temperature in my living-room, and when the Celsius is over “30”, i want a LED to react. Bellow you can see my coding (i’m totally beginner). I will not work :frowning:

  • Anyone who can help me, or will post the correct code? :frowning:

Thanks a lot for your time! :slight_smile:

- Mads Bach Laursen /Denmark

INFO:
LED = pin 13
SIGNAL = A0

HERE IS MY TRYING CODE:

int led = 13;

void setup() { //This function gets called when the Arduino starts
Serial.begin(115200); //This code sets up the Serial port at 115200 baud rate
int led = 13, OUTPUT;
}

void loop() { //This function loops while the arduino is powered
int val; //Create an integer variable
val=analogRead(0); //Read the analog port 0 and store the value in val
Serial.println(val); //Print the value to the serial port
delay(1000); //Wait one second before we do it again
if (Serial.println(val) < “30”);
{
digitalWrite, 13;
int led = HIGH;
}
}

there are just too many errors in your little program to comment on them all:

int led = 13;

void setup() 
{       
  Serial.begin(115200);   //This code sets up the Serial port at 115200 baud rate
  pinMode(led,OUTPUT);
}

void loop() 
{ 
  int val = analogRead(0);    //Read the analog port 0 and store the value in val
  Serial.println(val);    //Print the value to the serial port 
  if (val >= 30)
  {
    digitalWrite(led,HIGH);
  }
  else
  {
    digitalWrite(led,LOW);
  }
  delay(1000);  //Wait one second before we do it again
}

Thanks a lot!

  • You are ma hero today :smiley: :smiley: