Fssi Abhinay
Fssi Abhinay
Circuit in Tinkercad:
Code:
void setup ( )
{
pinMode (13, OUTPUT) ;
pinMode (13, OUTPUT) ;
pinMode (13, OUTPUT) ;
}
void loop ( )
{
digitalWrite (13, HIGH) ;
delay (1000) ;
digitalWrite (13, LOW) ;
delay (1000) ;
digitalWrite (12, HIGH) ;
delay (1000) ;
digitalWrite (12, LOW) ;
delay (1000) ;
digitalWrite (11, HIGH) ;
delay (1000) ;
digitalWrite (11, LOW) ;
delay (1000) ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
Circuit in Tinkercad:
Code:
void define_segment_pins(int a, int b, int c, int d, int e, int f, int g) /* Assigns 7-segment display pins to board
*/
{
disp_pin[0] = a;
disp_pin[1] = b;
disp_pin[2] = c;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
disp_pin[3] = d;
disp_pin[4] = e;
disp_pin[5] = f;
disp_pin[6] = g;
}
digitalWrite(disp_pin[4], HIGH);
digitalWrite(disp_pin[5], HIGH);
digitalWrite(disp_pin[6], LOW);
break;
case 4:
digitalWrite(disp_pin[0], HIGH);
digitalWrite(disp_pin[1], LOW);
digitalWrite(disp_pin[2], LOW);
digitalWrite(disp_pin[3], HIGH);
digitalWrite(disp_pin[4], HIGH);
digitalWrite(disp_pin[5], LOW);
digitalWrite(disp_pin[6], LOW);
break;
case 5:
digitalWrite(disp_pin[0], LOW);
digitalWrite(disp_pin[1], HIGH);
digitalWrite(disp_pin[2], LOW);
digitalWrite(disp_pin[3], LOW);
digitalWrite(disp_pin[4], HIGH);
digitalWrite(disp_pin[5], LOW);
digitalWrite(disp_pin[6], LOW);
break;
case 6:
digitalWrite(disp_pin[0], LOW);
digitalWrite(disp_pin[1], HIGH);
digitalWrite(disp_pin[2], LOW);
digitalWrite(disp_pin[3], LOW);
digitalWrite(disp_pin[4], LOW);
digitalWrite(disp_pin[5], LOW);
digitalWrite(disp_pin[6], LOW);
break;
case 7:
digitalWrite(disp_pin[0], LOW);
digitalWrite(disp_pin[1], LOW);
digitalWrite(disp_pin[2], LOW);
digitalWrite(disp_pin[3], HIGH);
digitalWrite(disp_pin[4], HIGH);
digitalWrite(disp_pin[5], HIGH);
digitalWrite(disp_pin[6], HIGH);
break;
case 8:
digitalWrite(disp_pin[0], LOW);
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
digitalWrite(disp_pin[1], LOW);
digitalWrite(disp_pin[2], LOW);
digitalWrite(disp_pin[3], LOW);
digitalWrite(disp_pin[4], LOW);
digitalWrite(disp_pin[5], LOW);
digitalWrite(disp_pin[6], LOW);
break;
case 9:
digitalWrite(disp_pin[0], LOW);
digitalWrite(disp_pin[1], LOW);
digitalWrite(disp_pin[2], LOW);
digitalWrite(disp_pin[3], LOW);
digitalWrite(disp_pin[4], HIGH);
digitalWrite(disp_pin[5], LOW);
digitalWrite(disp_pin[6], LOW);
break;
default:
digitalWrite(disp_pin[0], HIGH);
digitalWrite(disp_pin[1], LOW);
digitalWrite(disp_pin[2], LOW);
digitalWrite(disp_pin[3], LOW);
digitalWrite(disp_pin[4], LOW);
digitalWrite(disp_pin[5], HIGH);
digitalWrite(disp_pin[6], LOW);
break;
}
}
void setup ( ) {
pinMode (6, OUTPUT) ;
pinMode (7, OUTPUT) ;
pinMode (8, OUTPUT) ;
pinMode (9, OUTPUT) ;
pinMode (10, OUTPUT) ;
pinMode (11, OUTPUT) ;
pinMode (12, OUTPUT) ;
define_segment_pins (12, 11, 10, 9, 8, 7, 6) ;
}
void loop() {
int I ;
for(i = 9; i>=0; i--)
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
{
display_number (i) ;
delay (1000) ;
}
for(i = 0; i<=9; i++)
{
display_number (i) ;
delay(1000) ;
}
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
Circuit in Tinkercad:
Code:
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2 ;
LiquidCrystal lcd (rs, en, d4, d5, d6, d7) ;
byte Heart[8] = {
0b00000,
0b01010,
0b11111,
0b11111,
0b11111,
0b01110,
0b00100,
0b00000,
};
byte Sound[8] = {
0b00001,
0b00011,
0b00101,
0b01001,
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
0b01011,
0b11011,
0b11000,
};
void setup ( )
{
lcd.begin (16, 2) ;
lcd.createChar (0, Heart) ;
lcd.createChar (1, Sound) ;
lcd.setCursor (15, 0) ;
lcd.write (byte (0)) ;
lcd.setCursor (0, 1) ;
lcd.write (byte (0)) ;
lcd.setCursor (15, 1) ;
lcd.write (byte (0)) ;
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
Circuit in Tinkercad:
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd (12, 11, 5, 4, 3, 2) ;
int celsius ;
void setup ( )
{
Serial.begin (9600) ;
lcd.begin (16, 2) ;
lcd.setCursor (0, 0) ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
lcd.setCursor (0, 1) ;
lcd.print (celsius) ;
lcd.print (“C”) ;
Serial.println (Celsius) ;
delay (1000) ;
lcd clear ( ) ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
Circuit in Tinkercad:
Code:
#include <dht.h>
#include <LiquidCrystal.h>
const int rs =12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2 ;
LiquidCrystal lcd (rs, en, d4, d5, d6, d7) ;
#define outPin 8
dht DHT ;
void setup ( )
{
Serial.begin (9600) ;
lcd.begin (16, 2) ;
}
void loop ( )
{
int readData = DHT.read22 (outPin) ;
float t = DHT.temperature ;
float h = DHT.humidity ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
Serial.print (“Temperature = ”) ;
Serial.print (t) ;
Serial.print (“degree C = ”) ;
Serial.print ((t * 9.0 / 5.0+32.0)) ;
Serial.println (“degree F = ”) ;
Serial.print (“Humidity = ”) ;
Serial.print (h) ;
Serial.println (“ % ”) ;
Serial.println (“ ”) ;
lcd.setCursor (0, 0) ;
lcd.print (String (“Temp = ”) + String (t)) ;
lcd.setCursor (0, 1) ;
lcd.print (String (“Humidity = “) + String (h)) ;
delay (2000) ;
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 6: To design and implement a PIR sensor-based system that automatically
controls lights based on the presence or absence of motion, enhancing energy efficiency and convenience in a
home environment.
Circuit in Tinkercad:
Code:
int ledPin = 13 ;
int inputPin = 8 ;
int pirState = LOW ;
int val = 0 ;
void setup ( )
{
pinMode (ledPin, OUTPUT) ;
pinMode (inputPin, INPUT);
Serial.begin (9600) ;
}
void loop ( )
{
val = digitalRead (inputPin) ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
if (val == HIGH)
{
digitalWrite (ledPin, HIGH) ;
if (pitState == LOW)
{
pirState = HIGH ;
}
}
else
{
digitalWrite (ledPin, LOW) ;
if (pirState == HIGH)
{
pirState = LOW ;
}
}
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
Circuit in Tinkercad:
Code:
#include <LiquidCrystal.h>
#define max_distance 200
{
lcd.begin (16,2);
pinMode (trigPin, OUTPUT) ;
pinMode (echoPin, INPUT) ;
}
void loop ( )
{
digitalWrite (trigPin, LOW) ;
delayMicroseconds (2) ;
digitalWrite (trigPin, HIGH) ;
delayMicroseconds (10) ;
digitalWrite (trigPin, LOW) ;
distance = duration*0.034/2 ;
lcd.setCursor (0,0) ;
lcd.print ("Distance: ") ;
lcd.print (distance) ;
lcd.print (" cm") ;
delay (500) ;
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
Circuit in Tinkercad:
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd (5,6,7,8,9,10) ;
int irPin=2 ;
int count=0 ;
boolean state = true ;
void setup( )
{
Serial.begin(9600) ;
lcd.begin(16,2) ;
pinMode(irPin, INPUT) ;
lcd.setCursor(0,0) ;
lcd.print("Count No : ") ;
}
void loop( )
{
if (digitalRead(irPin) && state) {
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
count++ ;
state = false ;
Serial.print("0Count: ") ;
Serial.println(count) ;
lcd.setCursor(12,0) ;
lcd.print(count) ;
delay(100) ;
}
if (digitalRead(irPin))
{
state = true ;
delay(100) ;
}
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 9: Automatic Street Light Controller Using LDR Sensor.
Circuit in Tinkercad:
Code:
const int ledPin = 5 ;
const int ldrPin = A0 ;
void setup ( ) {
Serial.begin (9600) ;
pinMode (ledPin, OUTPUT) ;
pinMode (ldrPin, INPUT) ;
}
void loop ( )
{
int ldrStatus = analogRead(ldrPin) ;
if (ldrStatus <= 200) {
digitalWrite (ledPin, HIGH) ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 10: Add to the LED indication system to improve its effectiveness for gas
detection in safety-critical applications.
Circuit in Tinkercad:
Code:
int LED = A1 ;
const int gas = 0 ;
int MQ2pin = A0 ;
void setup ( ) {
Serial.begin (9600) ;
}
void loop ( )
{
float sensorValue, MQ2pin ;
sensorValue = analogRead(MQ2pin) ;
Serial.println (sensorValue) ;
}
delay (1000) ;
}
float getsensorValue (int pin)
{
return (analogRead (pin)) ;
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 11: Measuring Soil Moisture using Digital Output (D0).
Circuit in Tinkercad:
Code:
#define sensorPower 7
#define sensorPin 6
void setup ( )
{
pinMode (sensorPower, OUTPUT) ;
digitalWrite (sensorPower, LOW) ;
Serial.begin (9600) ;
}
int readSensor ()
{
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
void loop ( )
{
int val = readSensor () ;
Serial.print ("Digital Output: ") ;
Serial.println (val) ;
if (val == 0)
{
Serial.println ("Status: Soil is too dry - time to water!") ;
}
else
{
Serial.println ("Status: Soil moisture is perfect") ;
}
delay (1000) ;
Serial.println () ;
}
Circuit in Tinkercad:
Code:
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_LEDBackpack.h>
Adafruit_7segment matrix = Adafruit_7segment() ;
void setup ( )
{
matrix.begin(0x70) ;
}
void loop ( )
{
for (int numb = 0; numb <= 9999; numb++)
{
matrix.print (numb) ;
matrix.writeDisplay () ;
delay(200) ;
}
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 13: To control a DC motor's movement in left, right, forward, and
backward directions using Arduino.
Circuit in Tinkercad:
Code:
// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
// Motor B connections
int enB = 3 ;
int in3 = 5 ;
int in4 = 4 ;
void setup ( )
{
pinMode (enA, OUTPUT) ; // Set all the motor control pins to outputs
pinMode (enB, OUTPUT) ;
pinMode (in1, OUTPUT) ;
pinMode (in2, OUTPUT) ;
pinMode (in3, OUTPUT) ;
pinMode (in4, OUTPUT) ;
digitalWrite (in1, LOW) ; // Turn off motors - Initial state
digitalWrite (in2, LOW) ;
digitalWrite (in3, LOW) ;
digitalWrite (in4, LOW) ;
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
void loop ( )
{
directionControl () ; //Function is used to control the motor spin directions
//Only direction control function used for PostLab
delay(1000) ;
}
void directionControl ()
{
analogWrite (enA, 255) ;// Set motors to run at maximum speed (PWM range = 0 to 255 Max)
analogWrite (enB, 255) ;
//FORWARD
digitalWrite (in1, HIGH) ;
digitalWrite (in2, LOW) ;
digitalWrite (in3, HIGH) ;
digitalWrite (in4, LOW) ;
delay (2000) ;
//MOTORS OFF
digitalWrite (in1, LOW) ;
digitalWrite (in2, LOW) ;
digitalWrite (in3, LOW) ;
digitalWrite (in4, LOW) ;
delay(1000) ;
//BACKWARD
digitalWrite (in1, LOW) ;
digitalWrite (in2, HIGH) ;
digitalWrite (in3, LOW) ;
digitalWrite (in4, HIGH) ;
delay(2000) ;
//MOTORS OFF
digitalWrite (in1, LOW) ;
digitalWrite (in2, LOW) ;
digitalWrite (in3, LOW) ;
digitalWrite (in4, LOW) ;
delay(1000) ;
//RIGHT
digitalWrite (in1, HIGH) ;
digitalWrite (in2, LOW) ;
digitalWrite (in3, LOW) ;
digitalWrite (in4, HIGH) ;
delay(2000) ;
//MOTORS OFF
digitalWrite (in1, LOW) ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 14: Interfacing a FSR with Arduino and controlling an LED as an indicator
based on pressure.
Circuit in Tinkercad:
Code:
int ledPin = 7 ;
int ledPin2 = 6 ;
int ledPin3 = 5 ;
int fsrPin = A0 ;
int fsrReading ;
void setup ( )
{
Serial.begin (9600) ;
pinMode (fsrPin, INPUT) ;
pinMode (ledPin, OUTPUT) ;
pinMode (ledPin2, OUTPUT) ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 15: Interfacing a FSR with Arduino and controlling an LED as an indicator
based on pressure.
Circuit in Tinkercad:
Code:
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x20,16,2) ;
const byte ROWS = 4 ; //four rows
const byte COLS = 4 ; //four columns
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6} ; //connect to the row pinouts of the keypad
byte colPins [COLS] = {5, 4, 3, 2} ; //connect to the column pinouts of the keypad
//Create an object of keypad
Keypad keypad = Keypad ( makeKeymap(keys), rowPins, colPins, ROWS, COLS ) ;
void setup ( )
{
Serial.begin (9600) ;
lcd.init () ;
// turn on the backlight
lcd.backlight () ;
lcd.display () ;
}
void loop( )
{
char key = keypad.getKey () ;// Read the key
// Print if key pressed
if (key)
{
Serial.print ("Key Pressed: ") ;
Serial.println (key) ;
lcd.setCursor (0,0) ;
lcd.print(key) ;
}
}
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 16: To perform using the SPI communication protocol, where the Arduino
Mega is configured as the master device and the Arduino UNO as the slave. Data is transferred between the two
devices, demonstrating effective communication through SPI.
Circuit in Tinkercad:
Code:
#include <LiquidCrystal.h>
#define MISO 12
#define MOSI 11
#define PIN_CLOCK 13
#define CHIP_SELECT 10
int receivedTemperature ;
bool newDataReceived = false ;
void setup_pins ( )
{
DDRB &= ~((1 << 2) | (1 << 3) | (1 << 5)) ; // MOSI, PIN_CLOCK, CHIP_SELECT as
input DDRB |= (1 << 4) ; // MISO as output
DDRD = (0 << 2) | (0 << 3); //DDRC=0x00 ;
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Post Lab Exercise
sensor interfacing (01CT1103)
Name: Abhinay Reddy Date: Enrollment No: 92400133128
POST LAB EXERCISE 19: Add control for multiple LEDs connected to different GPIO pins and
control them through the Blynk app.
Code: