Name: Omkar Nandu Patil USN: 2JI18EC110 Roll No. /DIV: 52/A Sub: Embedded System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

Assignment-III

Name: Omkar Nandu Patil

USN: 2JI18EC110

Roll No. /DIV: 52/A

Sub: Embedded System

❖ Experiment No. 1

Aim: Interface DC MOTOR and Stepper Motor using TINKERCAD.


simulation tool.

Components: stepper motor, DC Motor, Arduino uno, Push Button,


potentiometer, connecting wires, Power Supply.

Circuit diagram:
Simulation output :

Program :

#include <Stepper.h>

const int stepsPerRevolution = 200;

int DCMotor = 2;

int PushButton = 7;

Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11)

int stepCount = 0;

void setup() {

pinMode(PushButton, INPUT);

pinMode(DCMotor , OUTPUT);
}

void loop() {

int estadoBoton = digitalRead(PushButton);

int sensorReading = analogRead(A0);

int motorSpeed = map(sensorReading, 0, 1023, 0, 100);

if (motorSpeed > 0) {

myStepper.setSpeed(motorSpeed);

myStepper.step(stepsPerRevolution / 100);

if(estadoBoton == 1){

digitalWrite(DCMotor , HIGH);

} else{

digitalWrite(DCMotor , LOW);

}
❖ Experiment No. 2

Aim : Interface (TMP36) Temperature sensor with LCD display using


TINKERCAD tool

Components : Arduino Uno, Potentiometer, LCD Display, Temperature


sensor (TMP36), Resistor(220 ohm) , Power supply, Connecting wire .

Circuit diagram:
Simulation output :

Serial Monitor

Program :
#include <LiquidCrystal.h>

#include <SoftwareSerial.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2); //connecting the pins


rs,en,d4,d5,d6,d7 to the arduino at pin 12 11 5 4 3 2

int celsius;

void setup()

Serial.begin(9600);

lcd.begin(16, 2); // Print a message to the LCD.

lcd.print(" Temp Display ");

Serial.println(" Temp Display ");

void loop(){

celsius = map(((analogRead(A0) - 20) * 3.04), 0, 1023, -40, 125);

lcd.setCursor(0,0);

lcd.print("Temp Display");

lcd.setCursor(0,1);

lcd.print(celsius);

lcd.print("C"); //print alphabet "c"


lcd.print("C"); //print alphabet "c"

Serial.println(celsius); //output shown in the serial monitor

delay(1000);

lcd.clear();

}
❖ Experiment No. 3

Aim : Interfacing Relay using TINKERCAD tool

Components : Arduino Uno, Power supply, Bulb, Relay, Connecting wire

Circuit diagram:

Simulation output :
Program :

void setup()

pinMode(3, OUTPUT);

void loop()

digitalWrite(3, HIGH);

delay(100); // Wait for 1000 millisecond(s)

digitalWrite(3, LOW);

delay(100); // Wait for 1000 millisecond(s)

}
❖ Experiment No. 4

Aim: Interfacing Optocouplers using TINKERCAD tool.

Components: Arduino Uno, Resistor(220 Ohm) , Optocoupler (4N35), 9v


Battery, Bulb, Connecting wires .

Circuit diagram:

Simulation output :
Program:

const int trig_pin = 2;

void setup() {

pinMode(trig_pin, OUTPUT);

void loop() {

digitalWrite(trig_pin,HIGH);

delay(1000);

digitalWrite(trig_pin, LOW);

delay(1000);

}
❖ Experiment No. 5

Aim: Interfacing 4x4 Keypad using TINKERCAD Tool.

Components: Arduino Uno, Keypad 4*4, Connecting wire, power suplly.

Circuit Diagram:

Simulation output:
Serial Monitor :

Program:

#include <Keypad.h>

const byte numRows= 4;

const byte numCols= 4;

char keymap[numRows][numCols]=

{'1', '2', '3', 'A'},

{'4', '5', '6', 'B'},

{'7', '8', '9', 'C'},

{'*', '0', '#', 'D'}

};

byte rowPins[numRows] = {9,8,7,6};

byte colPins[numCols]= {5,4,3,2};

//initializes an instance of the Keypad class


Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins,
colPins, numRows, numCols);

void setup()

Serial.begin(9600);

void loop()

char keypressed = myKeypad.getKey();

if (keypressed != NO_KEY)

Serial.println(keypressed);

}
❖ Experiment No. 6

Aim: Interfacing LED ON/OFF using external interrupts using TINKERCAD Tool.

Components: Arduino Uno, Resistor (10k ohm and 220 ohm), LED, Push
Button, Connecting wires.

Circuit Diagram:

Simulation output:
Program:

int ledpin=11;

int btnpin=2;

volatile int state = LOW;

void setup()

pinMode(ledpin,OUTPUT);

pinMode(btnpin, INPUT);

void loop()

if(digitalRead(btnpin)==LOW)

delay(10);

if(digitalRead(btnpin)==LOW)

while(digitalRead(btnpin) == LOW);

delay(10);

while(digitalRead(btnpin)==LOW);

state = !state;
digitalWrite(ledpin,state);

}
❖ Experiment No. 7

Aim: Interface UART communication using TINKERCAD Tool.

Components: Arduino Uno, Temperature Sensor(TMP 36), Piezo, Power


Supply, Connecting wire.

Circuit diagram:

Simulation output:
Serial Monitor:

Program:

/*char mystr[10]; //Initialized variable to store recieved data

void setup() {

Serial.begin(9600);

void loop() {

Serial.readBytes(mystr,5);

Serial.println(mystr);

delay(1000);

}*/

int val,T;

void setup() {
pinMode(6,OUTPUT);

digitalWrite(6,LOW);

Serial.begin(9600);

void loop() {

delay(1000);

int v = Serial.read();

/* if(T>=30)

digitalWrite(6,HIGH);

delay(5000);

else

digitalWrite(6,LOW);

delay(1000);

}*/

//Serial.println(val); //Print data on Serial Monitor

delay(1000);

}
❖ Experiment No. 8

Aim: Interfacing PWM using TINKERCAD Tool.

Components: Arduino Uno, Resistor (220 ohm ), LED, Oscilloscope, connecting

wires, power supply.

Circuit diagram:

Simulation output:
Program:

int led =9;

void rampa() {

for(int n=0;n<255;n++){

analogWrite(led, n);

delay(5);

void setup() {

pinMode(led, OUTPUT);

void loop() {

digitalWrite(led, HIGH);

delay(1000);

digitalWrite(led, LOW);

delay(1000);
}

You might also like