# Taking Input From User Through Serial Monitor

Hi guys, I’m new to Arduino coding, I grabbed this code online, and I was wondering how I could get input from the user as to what you can set the initial temperature as. The line of code where I’m talking about is:
if(temp>=16.00){digitalWrite(pin10,HIGH);}
Where I could set that 16.00 value as a value that the user would input.
Here is the code, thanks for your help!

float temp;
int tempPin = 0;
int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
void setup()
{
pinMode(pin2, OUTPUT);
pinMode(pin3, OUTPUT);
pinMode(pin4, OUTPUT);
pinMode(pin5, OUTPUT);
pinMode(pin7, OUTPUT);
pinMode(pin8, OUTPUT);
pinMode(pin9, OUTPUT);
pinMode(pin10, OUTPUT);
Serial.begin(9600);
}

void loop()
{
temp = (5.0 * temp * 100.0)/1024.0;
Serial.print(temp);
Serial.println();
if(temp>=16.00){digitalWrite(pin10,HIGH);}
if(temp>=17.00){digitalWrite(pin9,HIGH);}
if(temp>=18.00){digitalWrite(pin8,HIGH);}
if(temp>=19.00){digitalWrite(pin7,HIGH);}
if(temp>=20.00){digitalWrite(pin5,HIGH);}
if(temp>=21.00){digitalWrite(pin4,HIGH);}
if(temp>=22.00){digitalWrite(pin3,HIGH);}
if(temp>=23.00){digitalWrite(pin2,HIGH);}
delay(99);
digitalWrite(pin10,LOW);
digitalWrite(pin9,LOW);
digitalWrite(pin8,LOW);
digitalWrite(pin7,LOW);
digitalWrite(pin5,LOW);
digitalWrite(pin4,LOW);
digitalWrite(pin3,LOW);
digitalWrite(pin2,LOW);
delay(1);
}

UPDATE:Link doesn’t work, here is the code above

Temperature_Sensor.ino (1.07 KB)

I was wondering how I could get input from the user

If Serial.print() sends data to the Serial Monitor application, what do you suppose that Serial.available() and Serial.read() do?

I don’t know, I’m new to this. I only know the basics

Welcome to the Forum. Please read the three posts at the top of this Forum. The posts by Nick will tell you how to get the most from us, including using Ctrl-T in the IDE to format your code in a standard manner and then using code tags for posting it. Robin's intro post will likely answer most of your questions about using the Serial object in your programs. You can also search this site for additional details, too.

homidhomi4:
I don't know, I'm new to this. I only know the basics

The Reference page can help with your ignorance. Highly recommended.

The Thread planning and implementing a program contains a simple user input system

...R

Thanks Robin2