SlideShare a Scribd company logo
1 of 9
Download to read offline
Buzzer:
#include <lpc214x.h>
#define BUZZER_ON() IO1CLR=(1<<25)
#define BUZZER_OFF() IO1SET=(1<<25)
#define Count 100
void Buzzer_Delay(unsigned char j);
void Buzzer_Delay(unsigned char j)
{
unsigned int i;
for(;j>0;j--)
{
for(i=0; i<60000; i++);
}
}
int main(void)
{
PINSEL0 = 0x0000000;
PINSEL1 = 0x00000000;
PINSEL2 = 0x00000000;
IO1DIR = (1<<25) ;
while(1)
{
BUZZER_ON();
Buzzer_Delay(Count);
BUZZER_OFF();
}
}
LCD:
#include "lcd.h"
unsigned char Name[]="MyName";
unsigned char Surname[] = "Surname";
int main (void)
{
init_lcd();
lcd_putstring(0,Name);
lcd_putstring(1,Surname);
while (1) ;
}
-------------------------------not required to write if not asked for it-------------------------------------------
#ifndef _LCD_H
#define _LCD_H
#define MAX_CHAR_IN_ONE_LINE 16
enum ROW_NUMBERS
{
LINE1,
LINE2
};
void init_lcd(void);
void lcd_putstring(unsigned char line, char *string);
void lcd_clear(void);
void lcd_backlight_on(void);
int lcd_gotoxy(unsigned int x, unsigned int y);
void lcd_putchar(int c);
#endif
Down counter:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
void delay();
int main(void)
{
unsigned int b=255;
TRISA = 0x0000;
while(1)
{
PORTA=b;
delay();
delay();
b--;
if (!b)
{
delay();
delay();
delay();
delay();
b = 255;
}
}
}
void delay()
{
long int x;
for(x=0;x<90000;x++);
}
UP counter:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
void delay();
int main(void)
{
unsigned int b=1;
TRISA = 0x0000;
while(1)
{
PORTA=b;
delay();
delay();
b++;
if (!b)
{
delay();
delay();
delay();
delay();
b = 0x0000;
}
}
}
void delay()
{
long int x;
for(x=0;x<90000;x++);
}
Left shift:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
#define init_count 1
void delay();
unsigned int counter;
int main(void)
{
int i;
TRISA = 0x0000;
counter = init_count;
while(1)
{
for(i=0;i<8;i++)
{
PORTA=counter;
delay();
counter = counter << 1;
}
counter = 1;
}
}
void delay()
{
long int x;
for(x=0;x<90000;x++);
}
Right shift:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
#define init_count 128
void delay();
unsigned int counter;
int main(void)
{
int i;
TRISA = 0x0000;
counter = init_count;
while(1)
{
for(i=0;i<8;i++)
{
PORTA=counter;
delay();
counter = counter >> 1;
}
counter = 128;
}
}
void delay()
{
long int x;
for(x=0;x<60000;x++);
}
Voltage converter/ADC:
#include<p24fj128ga010.h>
_CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2)
_CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
#define init_count 128
int main(void)
{
unsigned int ADC_Result;
TRISA = 0x0000;
AD1CON1 = 0x80E4;
AD1CON2 = 0;
AD1CON3 = 0x1F05;
AD1CHS = 5;
TRISBbits.TRISB2 = 1;
TRISBbits.TRISB3 = 1;
AD1PCFGbits.PCFG5 = 0;
AD1CSSL = 0;
AD1CON1bits.ADON = 1;
while (1)
{
while(!AD1CON1bits.DONE);
ADC_Result = (long) ADC1BUF0;
ADC_Result >>= 7;
PORTA = (0x80 >> ADC_Result);
}
}
Note:
Device specific keywords in the program for ex: PORTA or TRISA etc are case sensitive.
Take care to ensure the cases in the program while executing.

More Related Content

What's hot

Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECERamesh Naik Bhukya
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programsbabak danyal
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab reportRamesh Naik Bhukya
 
Reporte de electrónica digital con VHDL: practica 7 memorias
Reporte de electrónica digital con VHDL: practica 7 memorias Reporte de electrónica digital con VHDL: practica 7 memorias
Reporte de electrónica digital con VHDL: practica 7 memorias SANTIAGO PABLO ALBERTO
 
To designing counters using verilog code
To designing counters using verilog codeTo designing counters using verilog code
To designing counters using verilog codeBharti Airtel Ltd.
 
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kitNon overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kitJatin Koshiya
 
26. composite l2qtouchpad
26. composite l2qtouchpad26. composite l2qtouchpad
26. composite l2qtouchpadMedia4math
 
Introduction to mazey
Introduction to mazeyIntroduction to mazey
Introduction to mazeytruncalen3
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINOS Ayub
 

What's hot (20)

Metal detecting robot sketch
Metal detecting robot sketchMetal detecting robot sketch
Metal detecting robot sketch
 
Alu description[1]
Alu description[1]Alu description[1]
Alu description[1]
 
Digital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECEDigital System Design Lab Report - VHDL ECE
Digital System Design Lab Report - VHDL ECE
 
Assignment#2
Assignment#2Assignment#2
Assignment#2
 
C test
C testC test
C test
 
Assignment#4a
Assignment#4aAssignment#4a
Assignment#4a
 
22 microcontroller programs
22 microcontroller programs22 microcontroller programs
22 microcontroller programs
 
Flex sensor
Flex sensorFlex sensor
Flex sensor
 
Embedded system design psoc lab report
Embedded system design psoc lab reportEmbedded system design psoc lab report
Embedded system design psoc lab report
 
C++20 features
C++20 features C++20 features
C++20 features
 
Reporte de electrónica digital con VHDL: practica 7 memorias
Reporte de electrónica digital con VHDL: practica 7 memorias Reporte de electrónica digital con VHDL: practica 7 memorias
Reporte de electrónica digital con VHDL: practica 7 memorias
 
Assignment#7b
Assignment#7bAssignment#7b
Assignment#7b
 
Assignment#7a
Assignment#7aAssignment#7a
Assignment#7a
 
To designing counters using verilog code
To designing counters using verilog codeTo designing counters using verilog code
To designing counters using verilog code
 
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kitNon overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
Non overlapped melay 1010 sequence detector implemented on xilinx spartan 3e kit
 
26. composite l2qtouchpad
26. composite l2qtouchpad26. composite l2qtouchpad
26. composite l2qtouchpad
 
Logic gates verification using universal gates
Logic gates verification using universal gatesLogic gates verification using universal gates
Logic gates verification using universal gates
 
Direct analog
Direct analogDirect analog
Direct analog
 
Introduction to mazey
Introduction to mazeyIntroduction to mazey
Introduction to mazey
 
CODING IN ARDUINO
CODING IN ARDUINOCODING IN ARDUINO
CODING IN ARDUINO
 

Similar to Microcontroller Programming Examples Collection</TITLE

codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controllerSyed Ghufran Hassan
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxSANTIAGO PABLO ALBERTO
 
Two digit-countdown-timer
Two digit-countdown-timerTwo digit-countdown-timer
Two digit-countdown-timerHEATLBJ
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureanishgoel
 
COA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfCOA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfJavedAnsari236392
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1kkkseld
 
Samrt attendance system using fingerprint
Samrt attendance system using fingerprintSamrt attendance system using fingerprint
Samrt attendance system using fingerprintpraful borad
 
Tai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhTai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhHồ Trường
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example Atit Gaonkar
 
include.docx
include.docxinclude.docx
include.docxNhiPtaa
 
Home automation system
Home automation system Home automation system
Home automation system Hira Shaukat
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPGFrankDin1
 
Operating system and embedded systems
Operating system and embedded systemsOperating system and embedded systems
Operating system and embedded systemsgayatrigayu1
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101premrings
 

Similar to Microcontroller Programming Examples Collection</TITLE (20)

codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Two digit-countdown-timer
Two digit-countdown-timerTwo digit-countdown-timer
Two digit-countdown-timer
 
C# Assignmet Help
C# Assignmet HelpC# Assignmet Help
C# Assignmet Help
 
8051 -5
8051 -58051 -5
8051 -5
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 
COA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdfCOA_remaining_lab_works_077BCT033.pdf
COA_remaining_lab_works_077BCT033.pdf
 
Microsoft Word Hw#1
Microsoft Word   Hw#1Microsoft Word   Hw#1
Microsoft Word Hw#1
 
Lập trình C
Lập trình CLập trình C
Lập trình C
 
Samrt attendance system using fingerprint
Samrt attendance system using fingerprintSamrt attendance system using fingerprint
Samrt attendance system using fingerprint
 
Tai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinhTai lieu ky thuat lap trinh
Tai lieu ky thuat lap trinh
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
 
include.docx
include.docxinclude.docx
include.docx
 
Home automation system
Home automation system Home automation system
Home automation system
 
Senior design project code for PPG
Senior design project code for PPGSenior design project code for PPG
Senior design project code for PPG
 
C++ assignment
C++ assignmentC++ assignment
C++ assignment
 
Asssignment2
Asssignment2 Asssignment2
Asssignment2
 
Operating system and embedded systems
Operating system and embedded systemsOperating system and embedded systems
Operating system and embedded systems
 
54602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee0108310154602399 c-examples-51-to-108-programe-ee01083101
54602399 c-examples-51-to-108-programe-ee01083101
 
VERILOG CODE
VERILOG CODEVERILOG CODE
VERILOG CODE
 

More from UVCE

Mathematics new syallbus copy by Lohith 11guee6018
Mathematics new syallbus copy by Lohith 11guee6018Mathematics new syallbus copy by Lohith 11guee6018
Mathematics new syallbus copy by Lohith 11guee6018UVCE
 
3rd 4th-sem-be-syllabus-lohith -11 guee6018
3rd 4th-sem-be-syllabus-lohith -11 guee60183rd 4th-sem-be-syllabus-lohith -11 guee6018
3rd 4th-sem-be-syllabus-lohith -11 guee6018UVCE
 
8 th sem syllabus
8 th sem syllabus8 th sem syllabus
8 th sem syllabusUVCE
 
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH KUMAR R 11GUEE...
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH  KUMAR R 11GUEE...UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH  KUMAR R 11GUEE...
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH KUMAR R 11GUEE...UVCE
 
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCEUVCE
 
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS 20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS UVCE
 
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018UVCE
 
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...UVCE
 
OFC problems for 8th sem Students UVCE
OFC problems for 8th sem Students UVCE OFC problems for 8th sem Students UVCE
OFC problems for 8th sem Students UVCE UVCE
 
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018UVCE
 
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018UVCE
 
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE60188th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018UVCE
 
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018UVCE
 
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018UVCE
 
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018UVCE
 
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018UVCE
 
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R UVCE
 

More from UVCE (17)

Mathematics new syallbus copy by Lohith 11guee6018
Mathematics new syallbus copy by Lohith 11guee6018Mathematics new syallbus copy by Lohith 11guee6018
Mathematics new syallbus copy by Lohith 11guee6018
 
3rd 4th-sem-be-syllabus-lohith -11 guee6018
3rd 4th-sem-be-syllabus-lohith -11 guee60183rd 4th-sem-be-syllabus-lohith -11 guee6018
3rd 4th-sem-be-syllabus-lohith -11 guee6018
 
8 th sem syllabus
8 th sem syllabus8 th sem syllabus
8 th sem syllabus
 
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH KUMAR R 11GUEE...
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH  KUMAR R 11GUEE...UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH  KUMAR R 11GUEE...
UVCE ELECTRONICS AND COMMUNICATION 7th SEM SYLLABUS BY LOHITH KUMAR R 11GUEE...
 
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
20150128162345995 OFC LAB EXPRIMENT FOR 8TH SEM STUDENTS AT UVCE
 
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS 20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
20150128163727950 ofc LAB EXPERIMENT CKT FOR 8TH SEM STUDENTS
 
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
How to work in keil software FOR 8TH SEM EC STUDENTS UVCE BY LOHITH |11GUEE6018
 
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
8th sem subject Optical fiber communications by gerd keiser uploaded by Lohit...
 
OFC problems for 8th sem Students UVCE
OFC problems for 8th sem Students UVCE OFC problems for 8th sem Students UVCE
OFC problems for 8th sem Students UVCE
 
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 8th chapter notes by Lohith kumar 11GUEE6018
 
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc 3rd chapter notes by Lohith kumar 11GUEE6018
 
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE60188th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject OFC 2nd chapter notes by Lohith kumar 11GUEE6018
 
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE60188th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
8th Sem Subject Ofc1st chapter notes by Lohith kumar 11GUEE6018
 
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 8th sem syllabus copy form lohith kumar 11guee6018
 
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 7th sem syllabus copy form lohith kumar 11guee6018
 
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
EC(UVCE) 6th sem syllabus copy form lohith kumar 11guee6018
 
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
BU (UVCE)5th Sem Electronics syllabus copy from Lohith kumar R
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 

Microcontroller Programming Examples Collection</TITLE

  • 1. Buzzer: #include <lpc214x.h> #define BUZZER_ON() IO1CLR=(1<<25) #define BUZZER_OFF() IO1SET=(1<<25) #define Count 100 void Buzzer_Delay(unsigned char j); void Buzzer_Delay(unsigned char j) { unsigned int i; for(;j>0;j--) { for(i=0; i<60000; i++); } } int main(void) { PINSEL0 = 0x0000000; PINSEL1 = 0x00000000; PINSEL2 = 0x00000000; IO1DIR = (1<<25) ; while(1) { BUZZER_ON(); Buzzer_Delay(Count); BUZZER_OFF(); } }
  • 2. LCD: #include "lcd.h" unsigned char Name[]="MyName"; unsigned char Surname[] = "Surname"; int main (void) { init_lcd(); lcd_putstring(0,Name); lcd_putstring(1,Surname); while (1) ; } -------------------------------not required to write if not asked for it------------------------------------------- #ifndef _LCD_H #define _LCD_H #define MAX_CHAR_IN_ONE_LINE 16 enum ROW_NUMBERS { LINE1, LINE2 }; void init_lcd(void); void lcd_putstring(unsigned char line, char *string); void lcd_clear(void); void lcd_backlight_on(void); int lcd_gotoxy(unsigned int x, unsigned int y); void lcd_putchar(int c); #endif
  • 3. Down counter: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) void delay(); int main(void) { unsigned int b=255; TRISA = 0x0000; while(1) { PORTA=b; delay(); delay(); b--; if (!b) { delay(); delay(); delay(); delay(); b = 255; } } }
  • 4. void delay() { long int x; for(x=0;x<90000;x++); } UP counter: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) void delay(); int main(void) { unsigned int b=1; TRISA = 0x0000; while(1) { PORTA=b; delay(); delay(); b++; if (!b) { delay();
  • 5. delay(); delay(); delay(); b = 0x0000; } } } void delay() { long int x; for(x=0;x<90000;x++); } Left shift: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) #define init_count 1 void delay(); unsigned int counter; int main(void) { int i; TRISA = 0x0000; counter = init_count;
  • 6. while(1) { for(i=0;i<8;i++) { PORTA=counter; delay(); counter = counter << 1; } counter = 1; } } void delay() { long int x; for(x=0;x<90000;x++); } Right shift: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI) #define init_count 128 void delay(); unsigned int counter; int main(void)
  • 7. { int i; TRISA = 0x0000; counter = init_count; while(1) { for(i=0;i<8;i++) { PORTA=counter; delay(); counter = counter >> 1; } counter = 128; } } void delay() { long int x; for(x=0;x<60000;x++); } Voltage converter/ADC: #include<p24fj128ga010.h> _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx2) _CONFIG2( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_XT & FNOSC_PRI)
  • 8. #define init_count 128 int main(void) { unsigned int ADC_Result; TRISA = 0x0000; AD1CON1 = 0x80E4; AD1CON2 = 0; AD1CON3 = 0x1F05; AD1CHS = 5; TRISBbits.TRISB2 = 1; TRISBbits.TRISB3 = 1; AD1PCFGbits.PCFG5 = 0; AD1CSSL = 0; AD1CON1bits.ADON = 1; while (1) { while(!AD1CON1bits.DONE); ADC_Result = (long) ADC1BUF0; ADC_Result >>= 7; PORTA = (0x80 >> ADC_Result); } }
  • 9. Note: Device specific keywords in the program for ex: PORTA or TRISA etc are case sensitive. Take care to ensure the cases in the program while executing.