0% found this document useful (0 votes)
15 views3 pages

IoT Lab 04

The document outlines a lab assignment on the Internet of Things, consisting of three tasks involving circuit diagrams and code for Arduino. Task 01 includes controlling digital pins based on serial input, Task 02 reads an analog value and converts it to voltage, and Task 03 demonstrates printing binary, octal, decimal, and hexadecimal values along with a string and character. Each task is accompanied by relevant code snippets for implementation.

Uploaded by

Ariba Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

IoT Lab 04

The document outlines a lab assignment on the Internet of Things, consisting of three tasks involving circuit diagrams and code for Arduino. Task 01 includes controlling digital pins based on serial input, Task 02 reads an analog value and converts it to voltage, and Task 03 demonstrates printing binary, octal, decimal, and hexadecimal values along with a string and character. Each task is accompanied by relevant code snippets for implementation.

Uploaded by

Ariba Amin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Internet Of Things

Lab 04

Task 01:
Circuit Diagram:

Code:

int A=0;
void setup() {
Serial.begin(9600);
while (!Serial);
for (int i = 4; i < 9; i++) {
pinMode(i, OUTPUT);
}}
void loop() {
if (Serial.available() > 0) {

char inByte = Serial.read();


switch (inByte) {
case 'a':
if (A%2!=1) {
digitalWrite(4, HIGH);}
else{ digitalWrite(4, LOW); }
A++;
break;
case 'b':
if (A%2!=1) {
digitalWrite(5, HIGH);
}
else {
digitalWrite(5, LOW);
}
A++;
break;
case 'c':
if (A%2!=1) {
digitalWrite(6, HIGH); }
else{ digitalWrite(6, LOW); }
A++;
break;
case 'd':
if (A%2!=1) {
digitalWrite(7, HIGH); }
else{ digitalWrite(7, LOW);
}
A++;
break;
case 'e':
if (A%2!=1) {
digitalWrite(8, HIGH); }
else{ digitalWrite(8, LOW);
}
A++;
break;
case 10:
break;
default:
for (int i = 4; i < 9; i++) {
digitalWrite(i, LOW);
}}}}

Task 02:
Circuit Diagram:

OutPut:

Code:

int analogPin = A0;


void setup() {
Serial.begin(9600);
} void loop() { int a = analogRead(A0); float voltage = ( a / 114); Serial.println(voltage);}
Task 03:

code:

void setup() {
Serial.begin(9600);
}

void loop() {
int binaryNumber = 101010;
Serial.print("Binary: ");
Serial.print(binaryNumber, BIN);
Serial.println();
delay(1000);
int octalNumber = 52;
Serial.print("Octal: ");
Serial.print(octalNumber, OCT);
Serial.println();
delay(1000);
int decimalNumber = 123;
Serial.print("Decimal: ");
Serial.print(decimalNumber, DEC);
Serial.println();
delay(1000);
int hexadecimalNumber = 0x7B;
Serial.print("Hexadecimal: ");
Serial.print(hexadecimalNumber, HEX);
Serial.println();
delay(1000);
String myString = "Hello, I am Haseeb";
Serial.println(myString);
delay(1000);
char myChar = 'A';
Serial.print("Character: ");
Serial.println(myChar);
delay(1000);
}

OutPut:

You might also like