ARM Full Manual
ARM Full Manual
Table of content
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Assembly language program, simulation -1
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
REPORT Total 25
VERIFICATION
Staff Name :
Signature :
Experiment 1
Programming arm LPC 1768 – Addition – Immediate addressing
Aim: Program to Add two Hexadecimal Numbers.
Software Used: KEIL
Target Microcontroller: ARM LPC1768
Algorithm:
Load your code in read only mode using the instruction AREA
PRAHELIKAEXPT1, CODE, READONLY.
Write your code in an ENTRY and END block.
Export your code module using the instruction EXPORT EXPTADD.
Load value 4 into r0 and load value 5 into r1using MOV instruction.
Add the values in r1 and r0 and store it in r2. Use a stop loop and end the program.
Program:
AREA PRAHELIKAEXPT1, CODE, READONLY
ENTRY
EXPORT EXPTADD
EXPTADD
MOV r0,#4 ;load 4
into r0 MOV r1,#5
;load 5 into r1
ADD r2,r0,r1 ;add r0 to r1 and put the
result in r2 Stop B Stop
END ;end of program
Simulation Output:
Program:
AREA PRAHELIKAEXPT2, CODE, READONLY
ENTRY
EXPORT EXPTADDTHREE
EXPTADDTHREE
MOV r1,#Q ;load r1 with the constant Q
MOV r2,#R
MOV r3,#S
ADD r0,r1,r2
ADD r0,r0,r3
Stop B Stop
Q EQU 2 ;Equate the symbolic name Q to the value 2
R EQU 4 ;
S EQU 5 ;
END
Simulation Output:
Result:
Addition of two Hexadecimal numbers is implemented in Keil software using the
ARM LPC 1768 Microcontroller.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Assembly language program, simulation 2
Date of Conduction :
Date of Submission :
Marks
Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 2
Result:
Addition of three Hexadecimal numbers is implemented in Keil software using the
ARM LPC 1768 Microcontroller.
Staff Name :
Signature :
Experiment 3
Program:
Simulation Output:
Pre lab:
1. Mention the use of the utility Digitalout()
2. What is the significance of using while(1) in most of the programs?
3. Give two examples of a conditional loop statements.
4. What is size of character, integer, integer pointer, character pointer?
5. What is type casting ?
Post lab:
1. Write a mbed code to count a sequence of 4 bits using GPIO and LED1-4.
2. Explain the output of the partial code
while(i>0) { //start conditional loop
yourled = 1;
wait(0.2);
yourled = 0;
wait(0.2);
i = i-1;
}
Result:
IO port programming is implemented in Keil software using the ARM LPC 1768
Microcontroller.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : PWM waveform generation using keil
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 4
#include <lpc214x.h>
while (1);
}
Simulation Output:
Pre lab:
1) What is GPIO direction register?
2) What is GPIO used for?
Post lab:
1) IO0DIR | = (1<<15); IO0SET | = (1<<15);
What does the above two lines indicate?
2) Which port is being used in this program? What is the change in code to select Port 0?
Result:
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Delay using Timer using keil
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 5
Delay using Timer using keil
while (1);
}
Simulation Output:
Result:
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : I2C Interfacing using keil
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 6
I2C Interfacing using keil
Aim: To perform I2C Interfacing in LPC2148 using keil
Program:
#include <lpc214x.h>
#include <stdint.h>
void I2C_INIT(void)
{
PINSEL0 = PINSEL0 | 0x00000050; /* Configure P0.2 and P0.3 as SCL0 and SDA0 respectively
*/
I2C0CONSET = 0x40; /* Enable I2C */
I2C0SCLL = 0x32; /* I2C data rate 300Khz and 50% duty cycle */
I2C0SCLH = 0x32; /* I2C data rate 300Khz and 50% duty cycle */
}
void I2C_START(void)
{
I2C0CONSET = 0x20; /* Set Start bit for Start condition */
while ( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x28; /* Clear Start bit and SI bit */
}
void I2C_WRITE( char data )
{
I2C0DAT = data; /* Load data to be written into the data register */
I2C0CONSET = 0x40; /* Enable I2C */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x08; /* Clear SI bit */
}
unsigned char I2C_READ_ACK( void )
{
I2C0CONSET = 0x44; /* Enable I2C with Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x0C; /* Clear SI and Acknowledge bits */
return I2C0DAT; /* Return received data */
}
unsigned char I2C_READ_NACK( void )
{
I2C0CONSET = 0x40; /* Enable I2C without Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x08; /* Clear SI bit */
return I2C0DAT; /* Return received data */
}
void I2C_MULTIREAD( char* arr , int bytes ) /* For reading multiple bytes at a time */
{
uint8_t i = 0;
while( ( bytes - 1 ) != 0 )
{
I2C0CONSET = 0x44; /* Enable I2C with Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x0C; /* Clear SI and Acknowledge bits */
*( arr + i ) = I2C0DAT ;
bytes--;
i++;
}
I2C0CONSET = 0x40; /* Enable I2C without Acknowledge */
while( (I2C0CONSET & 0x08) == 0 ); /* Wait till SI = 1 */
I2C0CONCLR = 0x08; /* Clear SI bit */
*( arr + i ) = I2C0DAT ;
}
void I2C_STOP( void )
{
I2C0CONSET = 0x50; /* Set Stop bit for Stop condition */
}
int main()
{
I2C_INIT();
I2C_START();
I2C_WRITE('c');
I2C_READ_ACK();
I2C_READ_NACK();
I2C_MULTIREAD("b",5);
I2C_STOP();
}
Simulation Output:
Pre lab Questions:
1) What are the limitations for the number of devices which can be connected to a single
SPI and I2C?
2) Draw up a table comparing the advantages and disadvantages for using SPI versus I2
C for serial communications.
Post Lab Questions:
1) An mbed configured as I2C Master is to be connected to three other mbeds, each configured as Slave.
Sketch a circuit which shows how this interconnection could be made. Explain your sketch.
2) An I2C link is running with a 500 kHz clock. How long does it take for a single
message containing one data byte to be transmitted?
Result:
Thus, the blinking of Led’s using switch is implemented successfully using
online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment :
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 7
DAC Interfacing using keil
Aim: To perform DAC Interfacing in LPC 2148 using keil
Software Used: KEIL
Algorithm:
Here, we will load the DACR value with various values to generate a sine wave, triangular wave,
sawtooth wave, square wave and DC wave.
4 switches are used as inputs on P0.8 (for sine wave), P0.9 (for triangular wave), P0.10 (for
sawtooth wave), and P0.11 (for square wave) pins.
These pins are connected to 3.3 V through pull-up resistors. Only switch for P0.8 Switches are
connected in a similar manner to the other 3 pins as well.
If we connect the DAC output pin P0.25 to an oscilloscope, we can observe the different waves.
Program:
#include <lpc214x.h>
#include <stdint.h>
void delay_ms(uint16_t j)
{
uint16_t x,i;
for(i=0;i<j;i++)
{
for(x=0; x<60000; x++); /* loop to generate 1 milisecond delay with Cclk = 60MHz */
}
}
436,359,282,216,211,151,97,55,25,6,0,6,25,55,97,151,211,216,282,359,436 };
i = 0;
PINSEL1 = 0x00080000; /* P0.25 as DAC output */
IO0DIR = ( IO0DIR & 0xFFFFF0FF ); /* Input pins for switch. P0.8 sine, P0.9 triangular, P0.10 sawtooth,
P0.11 square */
while(1)
{
if ( (IO0SET == 0x00000100)) /* If switch for sine wave is pressed */
{
while(i !=42)
{
value = sin_wave[i];
DACR = ( (1<<16) | (value<<6) );
delay_ms(1);
i++;
}
i = 0;
}
else if ((IO0SET==0x00000200)) /* If switch for triangular wave is pressed */
{
value = 0;
while ( value != 1023 )
{
DACR = ( (1<<16) | (value<<6) );
value++;
}
while ( value != 0 )
{
DACR = ( (1<<16) | (value<<6) );
value--;
}
}
else if ((IO0SET ==0x00000400)) /* If switch for sawtooth wave is pressed */
{
value = 0;
while ( value != 1023 )
{
DACR = ( (1<<16) | (value<<6) );
value++;
}
}
else if ((IO0SET ==0x00000800)) /* If switch for square wave is pressed */
{
value = 1023;
DACR = ( (1<<16) | (value<<6) );
delay_ms(100);
value = 0;
DACR = ( (1<<16) | (value<<6) );
delay_ms(100);
}
else /* If no switch is pressed, 3.3V DC */
{
value = 1023;
DACR = ( (1<<16) | (value<<6) );
}
}
}
Simulation Output:
Pre lab Questions:
1. What is the mbed’s DAC resolution and what is the smallest analog voltage step increase or
decrease which can be output from the mbed?
2. What is the output of the LPC1768 DAC, if its input digital word is a. 00 0000 1000
b. 0x80
c. 10 1000 1000?
while(1){
for (i=0;i<1;i=i+0.2){ Aout=i;
wait(0.1);
}
}
2. The program in Question gives a crude saw tooth waveform. What is its period?
3. The PWM on an mbed is set up with these statements. What is the on time of the waveform?
PWM1.period(0.004); // set PWM period
PWM1=0.75; // set duty cycle
Result:
The DAC Interfacing in LPC 2148 using keil was performed and 4 waveforms were
generated.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment :
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 8
Stepper motor interfacing using keil
Aim: To perform Stepper motor interfacing in LPC 2148 using keil
Software Used: KEIL
Algorithm:
Rotating stepper motor in clockwise and counter clockwise directions alternately.
Here, we are using six wire unipolar stepper motor. Only four wires are required to control
this stepper motor. The two centre tap wires of the stepper motor are connected to 5V supply.
ULN2003 driver is used to drive the stepper motor.
Note : To find winding coils and their centre tap leads, measure resistance in between the
leads. From centre leads we will get half the resistance value as compared to the resistance
between winding ends.
Program:
#include "mbed.h"
#include "C12832.h"
#include "Sht31.h"
C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);
Sht31 sht31(I2C_SDA, I2C_SCL);
DigitalOut led(LED1);
int main() {
printf("Set the temperature above 25 degrees to trigger the warning LED\n");
while (1) {
lcd.cls();
float temp = sht31.readTemperature();
float humidity = sht31.readHumidity();
lcd.locate(3, 3);
lcd.printf("Temperature: %.2f C", temp);
lcd.locate(3, 13);
lcd.printf("Humidity: %.2f %%", humidity);
// turn on LED if the temperature is above 25 degrees
led = temp > 25.0f;
wait(0.5f);
}
}
Simulation Output:
Prelab
1. Draw the 4 possible rotor positions and the corresponding stator excitations in a stepper motor
2. What is the specific property of the stepper motor which makes it compatible to interface with the
processor?
Post lab:
1. Modify the code to run in clockwise and anticlockwise alternatively?
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : ADC interfacing using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 9
ADC interfacing using mbed simulator
Aim: To explore mbed simulator – online and to perform A/D conversion, also view the
output in the serial output terminal
Software Used: mbed simulator
Algorithm:
1. Load the code in the simulator
2. Run the code
3. Set the temperature above 25 degrees to trigger the warning LED.
4. Set the temperature below 25 degrees to trigger the warning LED and cross-check
whether the output is correct
5. Save the output generated.
Program:
#include "mbed.h"
#include "C12832.h"
#include "Sht31.h"
C12832 lcd(SPI_MOSI, SPI_SCK, SPI_MISO, p8, p11);
Sht31 sht31(I2C_SDA, I2C_SCL);
DigitalOut led(LED1);
int main() {
printf("Set the temperature above 25 degrees to trigger the warning LED\n");
while (1) {
lcd.cls();
float temp = sht31.readTemperature();
float humidity = sht31.readHumidity();
lcd.locate(3, 3);
lcd.printf("Temperature: %.2f C", temp);
lcd.locate(3, 13);
lcd.printf("Humidity: %.2f %%", humidity);
// turn on LED if the temperature is above 25 degrees
led = temp > 25.0f;
wait(0.5f);
}
}
Simulation Output:
Pre lab Questions:
1. What do UART, CAN, I2C, and SPI stand for, and what do these mbed features have in common?
2. How many digital inputs are available on the mbed LPC1768?
Post Lab Questions:
1. A friend enters the code shown below into the mbed compiler, but when compiling, a number of
errors are flagged. Find and correct the faults.
#include mbed.h;
Digital Out myled(LED1);
int main() {
white(1)
{ myled = 1;
wait(0.2)
myled = 0;
wait(0.2);
}
2. Which mbed LPC1768 pins can be used for analog input and output?
Result:
Thus, the experiment A/D conversion is performed and the output is generated
successfully using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Binary counter using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 10
Program:
Post lab:
1. Write a mbed code to count a sequence of 4 bits using GPIO and LED1-4.
2. Explain the output of the partial code
while(i>0) { //start conditional loop
yourled = 1;
wait(0.2);
yourled = 0;
wait(0.2);
i = i-1;
}
3. State the significance of “=” and “= =” operator in mbed.
Result:
Thus, the experiment Binary counter is performed and the output is generated successfully using
online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : PWM tone generation using mbed simulator
ate of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 11
int main()
{
while(1) {
play_tone(200.0, 0.5, 1, 0);
play_tone(150.0, 0.5, 1, 0);
play_tone(125.0, 0.5, 1, 2);
}
Simulation Output:
Pre lab:
1. How to calculate the duty cycle of a PWM?
2. Define the relation between the duty cycle and period.
3. List any application of PWM in embedded system design
4. How to calculate the period of the PWM pulse?
5. How PWM is used to control motors?
Post Lab:
1. State any 3 standard function in mbed related to PWM
2. What will be the output of this program
#include "mbed.h"
PwmOut PWM1(p21)
int main()
{
PWM1.period(0.010);
PWM1=0.5;
}
Result:
Thus, the experiment PWM Sound generation is performed and the output is generated successfully
using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Interrupts and timers using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 12
Interrupts and timers using mbed simulator
Algorithm:
1. Load the code in the simulator
2. Initialize the color of screen and pen.
3. Initialize the LCD parameters
4. Run the code
5. Save the output generated
Program:
#include "mbed.h"
DigitalOut led1(LED1);
DigitalOut led2(LED2);
DigitalOut led3(LED3);
Ticker t1;
Timeout t2;
InterruptIn btn(BUTTON1);
void blink_led1() {
printf("Ticker fired\n");
led1 = !led1;
}
void toggle_led2() {
printf("BUTTON1 fall invoked\n");
led2 = !led2;
}
void turn_led3_on() {
printf("Timeout fired\n");
led3 = 1;
}
int main() {
printf("Hello world!\n");
printf("LED1 will blink every second, LED3 will toggle after 2.5 seconds, LED2 can be toggled
through BUTTON1.\n");
printf("-----------------------------------\n\n");
t1.attach(callback(&blink_led1), 1.0f);
t2.attach(callback(&turn_led3_on), 2.5f);
btn.fall(callback(&toggle_led2));
wait_ms(osWaitForever);
}
Simulation Output:
Prelab
1. InterruptIn btn(BUTTON1) – comment
2. Define a ticker
3. Differentiate ticker and interrupt
4. What is meant by timeout condition
5. How many timers are available in ARM LPC?
Post lab:
1. Why the above program is using callback( )
2. What is the significance if attach function.
Result:
Thus, the experiment on Interrupts and Timers is performed and the output is generated
successfully using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Touchscreen implementation using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 13
Algorithm:
1. Load the code in the simulator
2. Initialize the color of screen and pen.
3. Initialize the LCD parameters
4. Run the code
5. Save the output generated.
Program:
/**
* This is a demo which uses the ST DISCO_F413ZH LCD and touch screen
*/
#include "mbed.h"
#include "stm32f413h_discovery_ts.h"
#include "stm32f413h_discovery_lcd.h"
TS_StateTypeDef TS_State = { 0 };
int main() {
BSP_LCD_Init();
/* Touchscreen initialization */
printf("BSP_TS_Init error\n");
}
/* Clear the LCD */
BSP_LCD_Clear(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
BSP_LCD_SetFont(&Font16);
while (1) {
BSP_TS_GetState(&TS_State);
if(TS_State.touchDetected) {
uint16_t x1 = TS_State.touchX[0];
uint16_t y1 = TS_State.touchY[0];
BSP_LCD_SetTextColor(LCD_COLOR_RED);
wait_ms(10);
Simulation Output:
Prelab:
Post lab:
#define LCD_H
#include "mbed.h"
void toggle_enable(void);
void LCD_init(void);
endif
Result:
Thus, the experiment Touch screen -Pixel Graphics- Implementing on LCD is performed and the
output is generated successfully using online mbed simulator.
Laboratory Report Cover Sheet
SRM INSTITUTE OF SCIENCE AND TECHNOLOGY
Faculty of Engineering and Technology
Department of Electronics and Communication Engineering
18ECE204J ARM based Embedded System Design Lab
VI Semester, 2020-21 (Even Semester)
Name :
Register No. :
Venue : Virtual Lab
Title of Experiment : Graphics display using mbed simulator
Date of Conduction :
Date of Submission :
Marks
Particulars Max. Marks
Obtained
Pre Lab 05
Post Lab 05
Lab Performance 10
Lab Report 5
Total 25
REPORT VERIFICATION
Staff Name :
Signature :
Experiment 14
Algorithm:
1. Load the code in the simulator
2. Initialize the color of screen and pen.
3. Initialize the LCD parameters
4. Run the code
5. Save the output generated
Program:
#include "mbed.h"
#include "C12832.h"
// From https://os.mbed.com/users/dreschpe/code/Christmas-LCD
Bitmap bitmTree = {
36, // XSize
28, // YSize
5, // Bytes in Line
Tree, // Pointer to picture data
};
Bitmap bitmSan1 = {
17, // XSize
28, // YSize
3, // Bytes in Line
Santa1 , // Pointer to picture data
};
Bitmap bitmSan2 = {
17, // XSize
28, // YSize
3, // Bytes in Line
Santa2 , // Pointer to picture data
};
Bitmap bitmSan3 = {
17, // XSize
26, // YSize
3, // Bytes in Line
Santa3 , // Pointer to picture data
};
int main() {
printf("Demo by Peter Dresche\n");
printf("https://os.mbed.com/users/dreschpe/code/Christmas-LCD\n");
int i, s;
lcd.cls();
// lcd.set_font((unsigned char*) Arial_9);
s = 3;
lcd.print_bm(bitmTree, 95, 0); // print chistmas tree
lcd.copy_to_lcd();
lcd.setmode(XOR); // XOR - a second print will erase
for (i = -15; i < 75;) {
lcd.print_bm(bitmSan1, i, 2);
wait(0.2);
lcd.copy_to_lcd(); // update lcd
lcd.print_bm(bitmSan1, i, 2); // erase
i = i + s;
lcd.print_bm(bitmSan2, i, 2); // print next
wait(0.2);
lcd.copy_to_lcd(); // update lcd
lcd.print_bm(bitmSan2, i, 2); // erase
i = i + s;
lcd.print_bm(bitmSan3, i, 2); // print next
wait(0.2);
lcd.copy_to_lcd(); // update lcd
lcd.print_bm(bitmSan3, i, 2); // erase
i = i + s;
}
lcd.print_bm(bitmSan3, i, 2);
lcd.set_auto_up(0);
for (i = -20; i < 5; i++) { // scrolling text
lcd.locate(5, i);
lcd.printf("Happy");
lcd.locate(5, i + 12);
lcd.printf("Christmas");
lcd.copy_to_lcd();
lcd.locate(5, i);
wait(0.2);
lcd.printf("Happy");
lcd.locate(5, i + 12);
lcd.printf("Christmas");
lcd.copy_to_lcd();
i = i + 1;
}
lcd.locate(5, i);
lcd.printf("Happy");
lcd.locate(5, i + 12);
lcd.printf("Christmas");
lcd.copy_to_lcd();
printf("Done!\n");
}
Simulation Output:
Prelab:
Post lab:
Result:
Thus, the experiment Graphics Display using LCD is performed and the output is generated
successfully using online mbed simulator.