arduino session 3 course
arduino session 3 course
volt
temp
Example 2
Write a code to display the temperature
measured using LM35 on the seial monitor.
Code
# define lm35 A0
int ADCRead,voltage,temp;
void setup() {
Serial.begin(9600);}
void loop() {
ADCRead=analogRead(lm35);
voltage=ADCRead*4.88;
temp=voltage/10;
Serial.print("Temp=");
Serial.println(temp);
}
Proteus design
Tinker cad design
Operators
Arithmetic Operators
Relational Operators
Logical Operators
Bitwise Operators
Assignment Operators
Arithmetic operators
Operator name Operator simple Description Example
<
Checks if the value of left
operand is greater than the
greater than value of right operand, if yes (A > B) is not true
then condition becomes true.
#define led 8
#define switch1 2
#define switch2 3
void setup() {
pinMode(led,OUTPUT);
pinMode(switch1,INPUT);
pinMode(switch2,INPUT);}
void loop() {
if ((digitalRead(switch1)==LOW)&&(digitalRead(switch2)==LOW)){
digitalWrite(led,HIGH);}
else{ digitalWrite(led,LOW); }
}