Et3491-Embedded Systems and Iot Design
Et3491-Embedded Systems and Iot Design
Clear PSW
Select Register
ADD A & R0
Stop
EXP NO:
BASIC ARITHMETIC AND LOGICAL OPERATIONS USING 8051
DATE:
A. 8 BIT ADDITION
AIM:
To write a program to add two 8-bit numbers using 8051 microcontrollers.
ALGORITHM:
PROGRAM:
Address Output
4500 1A(LSB)
4501 00(MSB)
RESULT:
Thus the 8051 Assembly Language Program for addition of two 8 bit numbers was
executed.
FLOW CHART:
Start
IS
CF=1
Stop
B. 8 BIT SUBTRACTION
AIM:
To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
PROGRAM:
Address Output
4500 05
RESULT:
Thus the 8051 Assembly Language Program for subtraction of two 8 bit numbers was
executed.
FLOW CHART:
Start
Multiply A with B
Stop
C. 8 BIT MULTIPLICATION
AIM:
To perform multiplication of two 8 bit data and store the result in memory.
ALGORITHM:
Address Output
4500 0F(LSB)
4501 00(MSB)
RESULT:
Thus the 8051Assembly Language Program for multiplication of two 8 bit numbers was
executed.
FLOW CHART:
Start
Divide A by B
Stop
D. 8 BIT DIVISION
AIM:
To perform division of two 8 bit data and store the result in memory.
ALGORITHM:
PROGRAM:
Input Output
Memory Location Data Memory Location Data
4500 (dividend) 0F 4502 (remainder) 05
4501 (divisor) 03 4503 (quotient) 00
RESULT:
Thus the 8051 8051Assembly Language Program for division of two 8 bit numbers was
executed.
FLOW CHART:
START
STOP
D. MASKING BITS IN AN 8 – BIT NUMBER
AIM:
To write an assembly language program to mask bits o and 7 of an 8 – bit number and
store the result in memory using 8051 microcontrollers.
APPARATUS REQUIRED:
8051 microcontroller kit
ALGORITHM:
Masking bits in a 8 bit number
Start the process
Get the two data values
Get the second data
Logically „AND‟ the two data values.
Initialize the memory value and store the result in memory.
Start the process
PROGRAM:
Output
Memory Location Data
4500 06
RESULT:
Thus the 8051assembly language program for masking bits was executed and verified
a) 1‟s and 2‟s complement
START
STOP
E. SQUARE PROGRAM and FIND 2‟S COMPLEMENT OF A NUMBER
AIM:-
To write an assembly language to perform arithmetic, logical and bit manipulation instruction using
8051.
ALOGRITHM:
a) 1‟s and 2‟s complement
Get the value
Get the complement value of data.
Initialize the data pointer value as memory.
Move the complemented value to memory of data pointer.
Increment the value and memory.
Store the result in memory.
Stop the process.
a) 1‟s and 2‟s complement
PROGRAM:
Label Address Mnemonics Hex code Comments
Opcode Operand
4100 MOV A, #02 74, 02 Get the initial value
4102 CPL A F4 Complement the value
4103 MOV DPTR, # 4200 90, 42, 00 Initialize the memory
4106 MOVX @ DPTR, A F0 Move the data to memory
4107 INC A 04 Increment Accumulator
4108 INC DPTR A3 Increment the memory
4109 MOVX @ DPTR, A F0 Move the value to memory
ECE: 410A SJMP ECE 80, FE Continue the process.
Output
Memory Location Data
4200 FD (1‟s complement
4201 FE(2‟S Complement)
Square of a number
Input Output
Memory Location Data Memory Location Data
4200 89 4201 51
4202 49
b) SQUARE PROGRAM FOR 8051
$MOD51
ORG 4100H
MOV DPTR,#4200H
MOVX A,@DPTR
MOV B,A
MUL AB
INC DPTR
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @DPTR,A
L:SJMP L
RESULT:
Thus the assembly language program to find 2‟s complement, Square and cube of a number
was executed and verified successfully using 8051 microcontroller
FLOW CHART:
Start
Clear PSW
Select Register
ANL A & R1
Stop
EXP NO:
BASIC LOGICAL OPERATIONS USING 8051
DATE:
AIM:
To write a program to logical operation two 8-bit numbers using 8051 microcontrollers.
ALGORITHM:
logical program
ORG 0000H ; Start of program
; AND operation
ANL A, R1 ; A = A AND R1 => A = 10100000
MOV P1, A ; Output result to Port 1
ACALL DELAY ; Wait to view output
; OR operation
MOV A, #0F0H ; Reload A
ORL A, R1 ; A = A OR R1 => A = 11111010
MOV P1, A ; Output result
ACALL DELAY
; XOR operation
MOV A, #0F0H
XRL A, R1 ; A = A XOR R1 => A = 01011010
MOV P1, A
ACALL DELAY
; ---------------------
; Delay Subroutine
; ---------------------
DELAY:
MOV R2, #100
D1: MOV R1, #255
D2: DJNZ R1, D2
DJNZ R2, D1
RET
END
RESULT:
Thus the assembly language program of logical operation two 8-bit numbers was
executed and verified successfully using 8051 microcontroller
EXP NO: GENERATION OF SQUARE WAVEFORM
DATE USING 8051
AIM:
To Write & Test the Generation of Square Waveform Using 8051
PROGRAMME:
RESULT:
Thus the assembly language program of generation of Square Waveform was executed
and verified successfully using 8051 microcontroller
EXP NO: PROGRAMMING USING ON – CHIP PORTS IN 8051
DATE
AIM:
To Write & Test the programming Using On Chip Ports in 8051
PROGRAMME:
MAIN:
SETB P1.0 ; Turn ON LED (Set P1.0 high)
ACALL DELAY ; Call delay routine
CLR P1.0 ; Turn OFF LED (Clear P1.0)
ACALL DELAY ; Call delay routine
SJMP MAIN ; Repeat forever
; ---------------------
; Delay Subroutine
; ---------------------
DELAY:
MOV R2, #100 ; Outer loop counter
D1: MOV R1, #255 ; Inner loop counter
D2: DJNZ R1, D2 ; Decrement R1 until zero
DJNZ R2, D1 ; Repeat outer loop
RET
RESULT:
Thus the assembly language programming Using On Chip Ports was executed and
verified successfully using 8051 microcontroller
EXP NO:
AIM:
To Write & Test the programming Using Serial Port in 8051
PROGRAMME:
8051 TRANSMITTER PROGRAM:
RESULT:
Thus the assembly language programming Using Serial Port was executed and verified
successfully using 8051 microcontroller
EXP NO: DESIGN OF A DIGITAL CLOCK USING
DATE TIMERS/COUNTERS IN 8051
AIM:
To design of a digital clock using timers/counters in 8051
PROGRAMME:
DIGITAL CLOCK:
900F EA MOV A, R2
9017 0C INC R4
9018 EC MOV A, R4
901F 0A INC R2
1.27 cm
9020 7C 00 MOV R4,#00
9022 EA MOV A, R2
SECONDS SUBROUTINE:
ADDRESS LABEL OPCODE MNEMONICS
9200 7D 00 MOV R5, #00
9202 LOOP1 12 94 00 LCALL 9400
9205 0D INC R5
9206 ED MOV A, R5
9207 B4 60 F8 CJNE A, #60, 9202 (LOOP1)
920A 22 RET
MINUTES SUBROUTINE:
ADDRESS LABEL OPCODE MNEMONICS
9300 94 01 SUBB A, #01
9302 24 01 ADD A, #01
9304 D4 DA A
9305 FC MOV R4, A
9306 22 RET
HOURS SUBROUTINE:
ADDRESS LABEL OPCODE MNEMONICS
9310 94 01 SUBB A, #01
9312 24 01 ADD A, #01
9314 D4 DA A
9315 FA MOV R2, A
9316 22 RET
DELAY SUBROUTINE:
ADDRESS LABEL OPCODE MNEMONICS
9400 79 0A MOV R1,#0AH
9402 LOOP3 74 6F MOV A, #6FH
9404 LOOP4 00 NOP
9405 00 NOP
9406 00 NOP
9407 00 NOP
9408 14 DEC A
9409 70 F9 JNZ 9404
940B D9 F5 DJNZ R1,9402
940D 22 RET
RESULT:
Thus the assembly language of digital clock using timers/counters verified successfully
using 8051 microcontroller
1.27 cm
INTRODUCTION TO KEIL µ VISION 4 SOFTWARE
1.1 WELCOME
Thank you for purchasing the ARM CORTEX Tyro Board from Pantech ProLabs India
Pvt Ltd. The ARM CORTEX Tyro is a development board which demonstrates the
capabilities of the 144-pin LPC4088 devices.
The ARM CORTEX Tyro Board can be used as a stand-alone board built with an in-circuit
USB programmer. Sample programs are provided to demonstrate the unique features of the
supported devices.
The ARM CORTEX Tyro Board Kit comes with the following:
1. ARM CORTEX Tyro Development Board
2. Sample devices (LPC4088)
3. CD-ROM, which contains:
a) Sample programs
b) ARM CORTEX Tyro Development Board User’s Guide
4. 5V Adapter
5. Straight Female to Female serial cable
6. One Hook wire
7. USB Cable
Note: If you are missing any part of the kit, please contact our support executive
ARM CORTEX TYRO DEVELOPMENT BOARD
The ARM CORTEX TYRO development board has the following hardware features:
1.27 cm
CHAPTER 2: Hardware Details
CONNECTORS
40 pin FRC box type connector: Instead of terminating each port separately, this connector has all the
port pins. So More IO lines can be taken by using single cable.
The Ports are arranged as shown in the following figures
Similarly, two no. of 20x2 Connector gives access to various port lines.
GPIO CONNECTORS
J8
EXTENSION CONN
\
JUMPER DESCRIPTION
J6 ADC Selection: Place a jumper for the required channel; this will connect
LPC4088 pins with POT or LM35.
JP10 Connects the Buzzer with P0.26 or RTC alarm output pin
1.27 cm
POWER SUPPLY
The external power should be DC5V, 1A. The ARM board produces +3.3V using an onboard vol-
tage regulator, which provides supply to the ARMcontroler.
Power supply is controlled through slide switch SW1. The 5V volt from USB or DC JACK is used for
Peripherals directly
1.27 cm
STEP 2 – ERASE
5. Click Browse…
6.
7. Navigate to the project folder; Select the hex file to be loaded and Click Open.
Generally Verify after programming is required to cross check the burned hex file with the loaded hex
file and the remaining options left unchecked.
Programming Finished:
3.5 EXECUTION
1.27 cm
CHAPTER 4: Creating a Project in Keil
1.27 cm
STEP5: Select the Processor and Click Ok
1.27 cm
STEP 9: Save this file with “.c” Extension
STEP 11: Right Click on Source group and select add files to group
STEP 12: Select the source code file, click Add and then click close
1.27 cm
STEP 13: Navigate to the folder “C:\Keil\ARM\Startup\NXP\LPC407x_8x_177x_8x” and copy the file
“system_LPC407x_8x_177x_8x.c”
1.27 cm
STEP 17: Build the Project
STEP 18: Right Click “Target1” on the Project Tab and select Options for Target
STEP 19: On the Target Tab, Select the Floating point hardware as “Not used”
STEP 20: Select Output Tab and put a check mark on “Create HEX file”. The Name in the Text box “Name of
Executable” will be used to name the Hex file.
That’s
all. Now write your hex file into ARM CORTEX-M4 using Flash magicthe editor window.
1.27 cm
EXP NO:
Aim:
To develop and verify the interfacing ADC and DAC with LPC 4088 ARM microcontroller.
Apparatus Required:
PS-CORTEX – M4-TYRO-V4r2
Mini USB cable
Procedure:
1. Open keil
2. Select Project-> New M vision project
3. Create a project folder and name the project.
4. Select the processor and click ok ie, LPC4088 in NXP (For our device)
5. Create a new source file by selecting File-> New
6. Write the required source code.
7. Save the file with c extension
8. Right click on source group and select” add files to group”.
9. Select the source code file, click add and then click close.
10. Navigate the folder “c/keil/ARM/start up/NXP/LPC407x-8x-177x-8x” and
copy the file “System –LPC-407x-8x-177x-8x.c”.
11. Paste it in your project directory.
12. Right click on source group once again and select add files to group.
13. Now add this “System LPC 407x-8x-177x-8x-c”.
14. Build the project (F7).
15. Right click “Target” on the project tag and select optain for target.
16. On the target tag select the floating point hardware as not used.
17. Select output tag and but a check mark on “create hex file”.
18. In the linker tag, put a check mark on “use memory layout”….. and click ok.
19. Now rebuild the target and write your hex file into arm cortex m4 using flash
magic.
Procedure for Flash magic:
Click select
Expand ARM cortex from device database sources down and select your IC (here NxP->
LPC4088)
Click ok
Put a check mark on ”Erase blocks used by hex file check box”
Click browse
Navigate to the project folder, select the hex file to be loaded and click open.
Put a check mark on “verify after programming”.
Click start this will start programming the chip.
Press RESET after programming.
Interfacing ADC:
Power in the PCONP register, set the PCADC bit.
Configure pins p0, 23(CHO), P0,24,(CH1) and po,25 (CH2) as analog pins using their
respective 10CON registers ie., 10 CON-PO-23, to CON-PO-24 and 10 CON-PO-25.
Select ADC conversion check rate using ADC control register.
Enable power down [Normal CPU Mode]
Select the channel and start conversion.
Wait for the DONE bit, if the done bit is HIGH, the con version is completed.
Read the data register and store them in a variable.
Do the steps 5 to 7 for the remaining 2 channels.
Write those datas in hyper terminal via UARTO.
Hardware connection:
HARDWARE PIN CONNECTIONS OUTPUT
OUT
Turn ON DIP Switch (SW29) Digital Values of all the Three channels
Pins 7-(0.2) and 8-(0.3). will be displayed in UART
POT1 P0.24 Configure HyperTerminal @9600 baud Adjust the POT1 and POT2 or Apply
rate. temperature on LM35 to see the changes
Program ADC:
#include "LPC407x_8x_177x_8x.h"
#include<stdio.h>
int main(void)
{
init_adc();
init_serial();
while(1)
{
CH0=ADC_Getdata(0);
//Get data from channel0
itoa(CH0,Str);
//Convert the val to string
UART0_puts(Str);
//Step 9-Send the string to UART0
UART0_Txmt(' ');
//Space
CH1=ADC_Getdata(1);
//Step 8-Convert the 2nd channel
itoa(CH1,Str);
UART0_puts(Str);
//Step 9-Send ADC data to UART
UART0_Txmt(' ');
CH2=ADC_Getdata(2);
//Step 8-Convert the 3rd channel
itoa(CH2,Str);
UART0_puts(Str);
//Step 9-Send ADC data to UART
UART0_Txmt('\r');
//Carriage return, Enter Key
delay_ms(500);
}
}
void init_adc(void)
{
//1. set the PCADC bit
LPC_SC->PCONP |= (1 << 12);
/* enable power to ADC*/
//2. Configure pins P0.23, P0.24 and P0.25 as ADC input pins
LPC_IOCON->P0_23 = 1;
/* Pin P0.23 used as ADC0, IN0 */
LPC_IOCON->P0_24 = 1;
/* Pin P0.24 used as ADC0, IN1 */
LPC_IOCON->P0_25 = 1;
/* Pin P0.25 used as ADC0, IN2 */
//Derive baud rate from the UART clock source, Set DLAB=1
to access baud rate
//Register
//DLM:DLL=PCLK/(16*baud)= 30Mhz/(16*9600)= 195
LPC_UART0->DLL = 195; /* 9600 Baud
Rate @ 30.0 MHZ PCLK*/
LPC_UART0->DLM = 0; /* MSB = 0 */
LPC_UART0->LCR = 0x03; /* DLAB = 0*/
}
//Transmit a character
void UART0_Txmt(unsigned char Chr)
{
while((LPC_UART0->LSR & 0x20)==0);
//Bit5-THRE, Check THR empty or not
LPC_UART0->THR = Chr;
//Send the next character
}
//Receive a character
unsigned char UART0_Receive(void)
{
while((LPC_UART0->LSR & 0x01)==0);
//Bit0-RDR, Check receive data ready?
return(LPC_UART0->RBR);
//Read the data
}
//Transmit a string
void UART0_puts(unsigned char *string)
{
while(*string)
UART0_Txmt(*string++);
}
Program DAC:
#include "LPC407x_8x_177x_8x.h"
void init_dac(void);
void Write_DAC(unsigned int dacval);
void delay_ms(long ms) ;
int main(void)
{
init_dac();
while(1)
{
Write_DAC(0x3FF);
delay_ms(500);
Write_DAC(0);
delay_ms(500);
}
}
void init_dac(void)
{
Result
Thus the interfacing of ADC and DAC (in-built) with ARM processor has been verified and
observed the output successfully.
EXP NO:
Blinking of LEDs and LCD
DATE
Aim:
To verify the interrupt of LEDs and LCD in ARM development kit microprocessor board using
embedded C program
Apparatus Required:
PS-CORTEX-M4-TYRO-V4r2
Mini USB cable
Procedure:
For creating a project in keil
Open keil
Select project -> New project M vision project.
Create a project folder and name the project.
Select the processor and click ok ie, LPC 4088 in NXP (For our device)
Create a new source file by selecting file -> new.
Write the required source code.
Save the file with c extension.
Right click on source group and select “add files to group”.
Select the source code file/click add and then click close.
Navigate the folder “C\Keil\ARM\Startup\NXP\LPC407X-8X-177X-8X”and
copy the file”system-LPC-407X-8X-177X-8X.C”.
Paste it in your project directory.
Right click on source group once again and select add file to group.
Now add this “system LPC407X-8X-177X-8X.C.
Build the project (F7).
Right click “ target” on the project tag and select option for target.
On the target tag select the floating point hardware as not used .
Select output tag and put a check mark on “create hex file”
In the linker tag ,put a check mark on “use memory layout”…..and click ok.
Now rebuild the target and write your hex file into ARM CORTEX M4 use in
flash magic.
Procedure for Flash magic:
Click select
Expand ARM cortex from device database sources down and select your IC
(here NxP-> LPC4088)
Click ok
Put a check mark on ”Erase blocks used by hex file check box” Click browse
Navigate to the project folder, select the hex file to be loaded and click open.
Put a check mark on “verify after programming”. Click start this will start
programming the chip. Press RESET after programming.
Procedure For Flashing The Leds:
1. Power: In the PCONP register, set the PCGPIO bit
2. Configure pins P4.0 to P4.15 as GPIO pins i.e. IOCON_P4_0 to IOCON_P4_15.
3. Select LED pins P4.0 to P4.7 as output and SWITCH pins P4.8 to P4.15 as input
4. Read the Switch status and Display its value in LED
Hardware Connections:
Program:
Blinking of LEDs
#include "LPC407x_8x_177x_8x.h"
int main(void)
{
//1. Set the PCGPIO bit
LPC_SC->PCONP |= (1<<15);
Procedure:
1. Power: In the PCONP register, set the PCGPIO bit
2. Configure all the LCD pins as GPIO using IOCON registers
3. Configure all the LCD pins as outputs
4. Initialize LCD by sending initialization commands
Command software routine:
5. Make RS pin low
6. Place the MSB 4bits of command on data lines and Pulse the ENABLE pin
7. Place the LSB 4bits of command on data lines and Pulse the ENABLE pin
Data software routine:
8. Make RS pin high
9. Place the MSB 4bits of data on data lines and Pulse the ENABLE pin
10. Place the LSB 4bits of data on data lines and Pulse the ENABLE pin
11. Send First line command using command software routine
12. Send 16 characters of data using data software routine
13. Send Second line command using command software routine
14. Send 16 characters of data using data software routine
Connections:
HARDWARE PIN OUT CONNECTIONS OUTPUT
CONTROL LINES
RS P0.4
RW GND
EN P0.5
DATA LINES Turn ON DIP Switch (SW29) The Strings “CORTEX DEV
D0 - Pins 2-LCD+ BOARD” and “LCD DEMO
D1 - PROGRAM" will be displayed
D2 - on LCD.
D3 -
D4 P4.28
D5 P4.29
D6 P4.30
D7 P4.31
Program: LCD
#include "LPC407x_8x_177x_8x.h"
//data array
unsigned char Lcd_LINE1[]={"CORTEX DEV BOARD"},i=0;
unsigned char Lcd_LINE2[]={"LCD DEMO PROGRAM"};
int main(void)
{
while (1)
{
//11. Send First line command
lcd_command(0x80);
//12. Send 16 characters from the line1 array
for(i=0;Lcd_LINE1[i]!='\0';i++)
{
lcd_data(Lcd_LINE1[i]);
delay_ms(50);
}
void lcd_init(void)
{
delay_ms(100); //LCD powerup
time
lcd_command(0x33); //Wake up
lcd_command(0x32); //Wake up
lcd_command(0x28); //4bit mode
lcd_command(0x0C); //display on and
cursor off
lcd_command(0x06); //Entry mode and
shift
lcd_command(0x01); //Clear LCD
delay_ms(200); //Give more time
to settle
}
Result:
Thus the flashing of LEDs and LCD using ARM development kit board was observed by
using embedded C program successfully.
5 INTERFACING KEYBOARD AND STEPPER MOTOR
Aim:
To develop and verify the interfacing of keyboard and stepper motor with ARM development kit
and ARM microcontroller using embedded C program.
Apparatus Required:
PS CORTEX – M4- TYRO- V4r2
Mini VSB cable
Procedure:
For creating a project in keil
Open keil
Select project -> New project M vision project.
Create a project folder and name the project.
Select the processor and click ok ie, LPC 4088 in NXP (For our device)
Create a new source file by selecting file -> new.
Write the required source code.
Save the file with c extension.
Right click on source group and select “add files to group”.
Select the source code file/click add and then click close.
Navigate the folder “C\Keil\ARM\Startup\NXP\LPC407X-8X-177X-8X”and
copy the file”system-LPC-407X-8X-177X-8X.C”.
Paste it in your project directory.
Right click on source group once again and select add file to group.
Now add this “system LPC407X-8X-177X-8X.C.
Build the project (F7).
Right click “ target” on the project tag and select option for target.
On the target tag select the floating point hardware as not used .
Select output tag and put a check mark on “create hex file”
In the linker tag ,put a check mark on “use memory layout”…..and click ok.
Now rebuild the target and write your hex file into ARM CORTEX M4 use in
flash magic.
Hardware connection:
Turn on D/P switch sw29 pins 7 and 8.
Supply power to the board using sw1
Press and hold sw4 and press reset to enter into boot leader mode.
ROW1 P3.0
ROW2 P3.1
ROW3 P3.2
ROW4 P3.3 Turn ON DIP Switch (SW29) Press a Key (4x4 matrix
COL1 P3.4 Pins 2-LCD+ key- pad) and the number
will be displayed LCD
COL2 P3.5
COL3 P3.6
COL4 P3.7
Stepper Motor:
Power in the PCONP register, set the PCGP10 bit.
Configure all the LCD pins as GP10 using 10CON register.
Configure all the LCD pins as output.
Initialize LCD by sending initialization command.
COMMAND SOFTWARE ROUTINE:
Make RS pins low.
Place the MSB 4 bits of command on data line and pulse the enable pin.
Place the LSB 4 bits of command on data line and pulse the enable pin.
DATA SOFTWARE ROUTINE:
Make RS pins high.
Place the MSB 4 bits of command on data line and pulse the enable pin.
Place the LSB 4 bits of command on data line and pulse the enable pin.
Send the first line command using command software routine.
Send 16 characters of data and using command software routine.
Send 16 characters of data using data software routine.
Program:
Keyboard:
#include "LPC407x_8x_177x_8x.h"
//3. Configure all the row pins as output and make it HIGH
// Configure all the column pins as input and make it
void lcd_init(void)
{
delay_ms(100); //LCD powerup
time lcd_command(0x33); //Wake up
lcd_command(0x32); //Wake up
lcd_command(0x28); //4bit mode
lcd_command(0x0C); //display on and
to settle
}
void delay_ms(long ms) // delay 1 ms per
count @ CCLK 120 MHz
{
long i,j;
for (i = 0; i < ms; i++ )
for (j = 0; j < 26659; j++ );
}
Program:
Stepper Motor:
Procedure:
1. Power: In the PCONP register, set the PCGPIO bit
2. Configure pins P3.23 to P3.26 as GPIO pins using IOCON registers IOCON_P3_23 to
IOCON_P3_26
3. Configure the pins P3.23 to P3.24 as output pins using their direction registers.
4. Send the stepper sequence via IO lines
Connections:
HARDWARE PIN CONNECTIONS OUTPUT
OUT
Program:
Stepper Motor:
#include "LPC407x_8x_177x_8x.h"
int main(void)
{
//1. Set the PCGPIO bit
LPC_SC->PCONP |= (1<<15);
while(1)
{
//4. Send the stepper sequence
//Stepper Squence 1001,1100,0110,0011
LPC_GPIO3->PIN=(0x09<<23);
delay_ms(5);
LPC_GPIO3->PIN=(0x0c<<23);
delay_ms(5);
LPC_GPIO3->PIN=(0x06<<23);
delay_ms(5);
LPC_GPIO3->PIN=(0x03<<23);
delay_ms(5);
}
}
Result:
Thus the interfacing of keyboard and Stepper Motor with ARM development
kit and microcontroller using embedded C program has been verified successfully.
EXP NO: 9 GARBAGE SEGREGATOR AND BIN LEVEL
DATE INDICATOR
AIM:
Mini Project of Garbage Segregator and Bin Level Indicator
CONNECTION DIAGRAM:
PROGRAMME:
import numpy as np
import cv2
import RPi.GPIO as GPIO
import time
import pyttsx3
import I2C_LCD_Driver
import urllib.request
api_key = 'P47FDNAYU6MRM9WH'
#Garbage Segregator and Bin Level Indicator
mylcd = I2C_LCD_Driver.lcd()
mylcd.lcd_display_string(" Bin Level ", 1)
mylcd.lcd_display_string(" Indicator ", 2)
#GPIO Mode (BOARD / BCM)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
#set GPIO Pins
GPIO_TRIGGER = 23
GPIO_ECHO = 24
#set GPIO direction (IN / OUT)
GPIO.setup(GPIO_TRIGGER, GPIO.OUT)
GPIO.setup(GPIO_ECHO, GPIO.IN)
engine.say('Welcome')
engine.runAndWait()
mylcd.lcd_clear()
mylcd.lcd_display_string("BIN LEVEl 1= 0 ", 1)
mylcd.lcd_display_string("BIN LEVEl 2= 0 ", 2)
baseURL = 'https://api.thingspeak.com/update?api_key=%s' % api_key
while(True):
ret, img = video_capture.read()
#frame = cv2.resize(img,(0,0),fx=0.5, fy=0.5)
frame = cv2.resize(img,(400,350))
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = detector.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow('img',frame)
cv2.waitKey(1)
bin_1 = distance_1()
#bin_1 = input("bin_1=")
bin_2 = distance_2()
#bin_2 = input("bin_2=")
print ("Measured = "+ str(bin_1) +" "+ str(bin_2))
mylcd.lcd_clear()
if ((bin_1 == 100) and (bin_2 == 100)):
mylcd.lcd_display_string("Both bin full,Pls", 1)
mylcd.lcd_display_string("use anyother bin ", 2)
string = ("Both bin level is full, please use any other bin")
elif(bin_1 == 100):
mylcd.lcd_display_string("BIN LEVEl 1= full", 1)
mylcd.lcd_display_string("BIN LEVEl 2= "+str(int(bin_2)), 2)
string = ("first bin is full and" + "Second bin level is" + str(int(bin_2)))
elif(bin_2 == 100):
mylcd.lcd_display_string("BIN LEVEl 1= "+str(int(bin_1)), 1)
mylcd.lcd_display_string("BIN LEVEl 2= full", 2)
string = ("first bin level is" + str(int(bin_1)) + "and Second bin full")
else:
mylcd.lcd_display_string("BIN LEVEl 1= "+str(int(bin_1)), 1)
mylcd.lcd_display_string("BIN LEVEl 2= "+str(int(bin_2)), 2)
string = ("first bin level is" + str(int(bin_1)) + "and" + "Second bin level is" + str(int(bin_2)))
f = urllib.request.urlopen(baseURL+"&field1=%s&field2=%s" % (bin_1,bin_2))
print(f.read())
f.close()
engine.say(string)
engine.runAndWait()
time.sleep(5)
cv2.imshow('img',frame)
if(cv2.waitKey(1)==ord('q')):
break
video_capture.release()
cv2.destroyAllWindows()
Result:
Thus the mini project of Garbage Segregator and Bin Level Indicator has been
verified successfully.
EXP NO: 10 COLOUR BASED PRODUCT SORTING
DATE MACHINES
AIM:
Mini Project of Colour based Product Sorting Machines
CONNECTION DIAGRAM:
PROGRAMMES:
import cv2
import RPi.GPIO as GPIO
import time
import numpy as np
import I2C_LCD_Driver
import urllib.request
api_key = 'P47FDNAYU6MRM9WH'
#2 to 12.5
#Colour based Product Sorting
mylcd = I2C_LCD_Driver.lcd()
mylcd.lcd_display_string(" Coloue Based ", 1)
mylcd.lcd_display_string("Product Sorting ", 2)
servoPIN = 17
servoPIN_2 = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(servoPIN, GPIO.OUT)
GPIO.setup(servoPIN_2, GPIO.OUT)
webcam = cv2.VideoCapture(0)
start_position = 5.0
camera_stop = 6.6
end_position = 9.8
step_delay = 0.05
step_angle = 0.1
except KeyboardInterrupt:
p.stop()
GPIO.cleanup()
webcam.release()
cv2.destroyAllWindows()
p.stop()
p_2.stop()
GPIO.cleanup()
Result:
Thus the mini project of Colour based Product Sorting Machines has been
verified successfully.
EXP NO: 11 IMAGE PROCESSING BASED FIRE DETECTION
DATE
AIM:
Mini Project of Image Processing based Fire Detection
CONNECTION DIAGRAM:
PROGRAMMES:
import I2C_LCD_Driver
from time import *
import numpy as np
import cv2
mylcd = I2C_LCD_Driver.lcd()
mylcd.lcd_display_string(" Megatronics ", 1)
mylcd.lcd_display_string(" Fire Detecting ", 2)
fire_cascade = cv2.CascadeClassifier('cascade.xml')
Result:
Thus the mini project of Image Processing based Fire Detection has been
verified successfully.
EXP NO: 12 VEHICLE NUMBER PLATE DETECTION
DATE
AIM:
Mini Project of Vehicle Number Plate Detection
CONNECTION DIAGRAM:
PROGRAMMES:
import cv2
import numpy as np
cap.release()
cv2.destroyAllWindows()
Result:
Thus the mini project of Vehicle Number Plate Detection has been verified
successfully.
EXP NO: 13 Smart Lock System
DATE
AIM:
Mini Project of Smart Lock System
CONNECTION DIAGRAM:
PROGRAMMES:
#include"LiquidCrystal_I2C.h"
#define PR1 2
#define PR2 3
#define PR3 4
#define PR4 5
#define PC1 6
#define PC2 7
#define PC3 8
#define G_LED 10
#define B_LED 11
#define R_LED 12
#define Buzzer 13
#define relay 9
#define RR1 digitalRead(PR1)
#define RR2 digitalRead(PR2)
#define RR3 digitalRead(PR3)
#define RR4 digitalRead(PR4)
//LiquidCrystal_I2C lcd(0x3F,16,2);
LiquidCrystal_I2C lcd(0x27,16,2);
uint8_t key;
uint8_t count;
uint8_t securitykey[4];
uint8_t get_key[4];
uint8_t Read_keypad()
{
uint8_t colum;
uint8_t result = '-';
for(colum = 0; colum <= 2; colum++)
{
switch(colum)
{
case 0:
digitalWrite(PC1, LOW);
digitalWrite(PC2, HIGH);
digitalWrite(PC3, HIGH);
break;
case 1:
digitalWrite(PC1, HIGH);
digitalWrite(PC2, LOW);
digitalWrite(PC3, HIGH);
break;
case 2:
digitalWrite(PC1, HIGH);
digitalWrite(PC2, HIGH);
digitalWrite(PC3, LOW);
break;
default:
colum = 0;
return result;
break;
}
if(RR1 == LOW)
{
Serial.print(colum);
Serial.println(" RR1");
result = keys[0][colum];
break;
}
else if(RR2 == LOW)
{
Serial.print(colum);
Serial.println(" RR2");
result = keys[1][colum];
break;
}
else if(RR3 == LOW)
{
Serial.print(colum);
Serial.println(" RR3");
result = keys[2][colum];
break;
}
else if(RR4 == LOW)
{
Serial.print(colum);
Serial.println(" RR4");
result = keys[3][colum];
break;
}
}
return result;
}
void new_key_disp(void)
{
lcd.setCursor(0,0);
lcd.print("New Security Key");
lcd.setCursor(0,1);
lcd.print("Type: ");
}
void get_key_disp(void)
{
lcd.setCursor(0,0);
lcd.print("Welcome to home ");
lcd.setCursor(0,1);
lcd.print("Key : ");
}
void get_securitykey(uint8_t *sec_key)
{
count = 0;
while(count < 4)
{
key = Read_keypad();
if(key != '-')
{
sec_key[count] = key;
lcd.setCursor(5+count,1);
lcd.print("*");
count++;
}
delay(1000);
}
}
uint8_t compareky(uint8_t* cmp1, uint8_t* comp2)
{
uint8_t i,ret = 1;
for(i=0;i<4;i++)
{
if(cmp1[i] != comp2[i])
{
ret =0;
break;
}
}
return ret;
}
void setup()
{
lcd.init();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" Megatronics ");
lcd.setCursor(0,1);
lcd.print("Door Lock system");
lcd.backlight();
pinMode(PR1, INPUT_PULLUP);
pinMode(PR2, INPUT_PULLUP);
pinMode(PR3, INPUT_PULLUP);
pinMode(PR4, INPUT_PULLUP);
pinMode(PC1, OUTPUT);
pinMode(PC2, OUTPUT);
pinMode(PC3, OUTPUT);
pinMode(G_LED, OUTPUT);
pinMode(B_LED, OUTPUT);
pinMode(R_LED, OUTPUT);
pinMode(Buzzer, OUTPUT);
pinMode(relay, OUTPUT);
digitalWrite(G_LED, LOW);
digitalWrite(B_LED, HIGH);
digitalWrite(R_LED, LOW);
digitalWrite(relay, HIGH);
digitalWrite(Buzzer, HIGH);
Serial.begin(9600);
delay(2000);
new_key_disp();
get_securitykey(&securitykey[0]);
}
void loop()
{
uint8_t ret;
get_key_disp();
get_securitykey(&get_key[0]);
ret = compareky(&securitykey[0],&get_key[0]);
if(ret == 1)
{
lcd.setCursor(0,0);
lcd.print("Key matched ");
lcd.setCursor(0,1);
lcd.print("Door opened ");
digitalWrite(G_LED, HIGH);
digitalWrite(B_LED, LOW);
digitalWrite(R_LED, LOW);
digitalWrite(Buzzer, LOW);
digitalWrite(relay, LOW);
delay(1000);
digitalWrite(Buzzer, HIGH);
delay(4000);
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Door closed ");
digitalWrite(G_LED, LOW);
digitalWrite(B_LED, HIGH);
digitalWrite(relay, HIGH);
delay(2000);
}else{
lcd.setCursor(0,0); lcd.print("Key
not matched "); lcd.setCursor(0,1);
lcd.print(" ");
digitalWrite(G_LED, LOW);
digitalWrite(B_LED, LOW);
digitalWrite(R_LED, HIGH);
digitalWrite(Buzzer, LOW);
while(1)
{
key = Read_keypad();
if(key == '#')
{
lcd.clear(); digitalWrite(G_LED,
LOW); digitalWrite(B_LED,
HIGH); digitalWrite(R_LED,
LOW); digitalWrite(Buzzer,
HIGH); delay(1000);
break;
}
}
}
delay(100);
}
Result:
Thus the mini project of Smart Lock System has been verified successfully.