Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

EX - NO: 1 Linux Kernal Compilation Date

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

EX.

NO: 1
LINUX KERNAL COMPILATION

DATE:

Aim:
To upgrade the kernel file of the linux operating system using kernel compilation
process.
Apparatus Required:
1. Linux OS
2. Virtual Machine
Description:
Linux kernel compilation provides the user to unlock the features which are not
available for the standard users. Linux compilation process allows the users to modify their
kernel depending on their hardware and software application environment. Following points
shows the steps involved in compiling a kernel.
Building Linux Kernel
The process of building a Linux kernel can be performed in seven easy steps. However, the
procedure may require a significant amount of time to complete, depending on the system
speed.

Follow the steps below to build the latest Linux kernel.

Step 1: Download the Source Code


1. Visit the official kernel website and download the latest kernel version. The downloaded file
contains a compressed source code.
2. Open the terminal and use the wget command to download the Linux kernel source code:
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.0.7.tar.xz
The output shows the “saved” message when the download completes.

Step 2: Extract the Source Code


When the file is ready, run the tar command to extract the source code:
tar xvf linux-6.0.7.tar.xz
The output displays the extracted kernel source code:

Step 3: Install Required Packages


Install additional packages before building a kernel. To do so, run this command:
sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-
dev bison
The command we used above installs the essential packages for performing Linux kernel
compilation
Step 4: Configure Kernel
The Linux kernel source code comes with the default configuration. However, you can adjust
it to your needs. To do so, follow the steps below:
1. Navigate to the linux-6.0.7 directory using the cd command:
cd linux-6.0.7
2. Copy the existing configuration file using the cp command:
cp -v /boot/config-$(uname -r) .config

3. To make changes to the configuration file, run the make command:


make menuconfig
The command launches several scripts that open the configuration menu:
4. The configuration menu includes options such as firmware, file system, network, and
memory settings. Use the arrows to make a selection or choose Help to learn more about the
options. When you finish making the changes, select Save, and then exit the menu.

Note:
Changing settings for some options can lead to a non-functional kernel. If you are
unsure what to change, leave the default settings.

Step 5: Build the Kernel


1. Start building the kernel by running the following command:
make
• The process of building and compiling the Linux kernel takes some time to complete.
• The terminal lists all Linux kernel components: memory management, hardware device
drivers, filesystem drivers, network drivers, and process management.

If you are compiling the kernel on Ubuntu, you may receive the following error that interrupts
the building process:
No rule to make target 'debian/canonical-certs.pem
Disable the conflicting security certificates by executing the two commands below:
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS
The commands return no output. Start the building process again with make, and
press Enter repeatedly to confirm the default options for the generation of new certificates.

2. Install the required modules with this command:


sudo make modules_install

3. Finally, install the kernel by typing:


sudo make install
The output shows done when finished:

Step 6: Update the Bootloader (Optional)


The GRUB bootloader is the first program that runs when the system powers on.
The make install command performs this process automatically, but you can also do it
manually.
1. Update the initramfs to the installed kernel version:
sudo update-initramfs -c -k 6.0.7
2. Update the GRUB bootloader with this command:
sudo update-grub
The terminal prints out the process and confirmation message:
Step 7: Reboot and Verify Kernel Version
When you complete the steps above, reboot the machine.
When the system boots up, verify the kernel version using the uname command:
uname -mrs
The terminal prints out the current Linux kernel version.

Result:
Thus, the procedure was followed and the kernel file of Linux OS was updated.
EX.NO: 2
UTILIZATION OF GNU TOOLCHAINS FOR
EFFECTIVE SYSTEM PROGRAMMING
DATE:

Aim:
• To develop a C program and execute various GNU Bin Utils tools.
• To debug a C program using GDB tools in a Linux system.
Software requirement:
• Ubuntu Linux distros
• Text editors like gedit, vi in Linux with gcc
Procedure:
• Develop a C program main.c in gedit text editor.
• Create C files mul.c, div.c in gedit text editor which contains the prototype of the main
program module main.c
• Create a header with .h in gedit and insert the prototype signatures into the header file
head.h.
• Include the header head.h in main.c program.
• After the creation of these files, start building the executable files as follows in the terminal.
// Creation of object files
$ gcc –c mul.c
$ gcc –c div.c
$ gcc –i main.c
• Create a static library using GNU Bin Utils tool (ar)
$ ar rs libhead.a mul.o div.o
• Link the object files to create executable file
$ gcc -o main main.o libhead.a (or)
$ gcc -o pattern -L . pattern.o -I pattern.a
• Apply different GNU tool chains [GDB, Bin Utils (objdump, nm, strings, strips)] and
observe the generated output from the terminal window.

Program:
Program for Head.h
int mul(int,int);
int div(int,int);

Program for mul.c


int mul(a,b)
{
return(a*b);
}
Program for div.c
int div(c,d)
{
return(c/d);
}

Program for main.c


# include <stdio.h>
# include “Head.h”
void main()
{
int x;
int y;
printf(“Enter x,y \n”);
scanf(“%d %d”, &x,&y);
printf(“%d”,mul(x,y));
printf(“%d”,div(x,y));
}

Commands:
• $ gcc -c mul.c
• $ gcc -c div.c
• $ gcc -c main.c
• $ ar rs libhead.a mul.o div.o
• $ gcc -o main main.o libhead.a
• objdump main.o
• strings main.o
• size main.o
• nm main.o
• strip main.o

Program to reverse the number:


#include<stdio.h>
int main()
{
int n,rev=0;
printf(“Enter the number:\n”);
scanf(“%d”,&n);
while(n!=0)
{
rev=rev *10 + (n%10);
n=n/10;
}
printf(“Enter the reverse number=%d\n”,rev);
return 0;
}
Compile the program and execute the following steps:
• gcc -g filename.c
• gdb -q a.out
Output:

Result:
Thus, different GNU tools were applied for the developed ‘C’ program and the output
from the terminal window was observed and verified successfully.
EX.NO: 3
DEBUGGING PROGRAMS USING CSCOPE

DATE:

Aim:
To familiarize basic Cscope tools and experiment it using a C program.
Software requirement:
• Ubuntu Linux distros.
• Text editor like gedit
• Cscope tools
Procedure:
• Develop a c program in gedit text editor.
• Compile the developed c program in terminal window.
• Enter the command Cscope in terminal window.
• If not installed Cscope, install using sudo apt-get install Cscope.
• Use Cscope options for the developed C program and observe the results in terminal.
window.
Theory:
• Cscope is an interactive,screen oriented tool that allows the user to browse through c
source files for specified elements of code.
• By default, Cscope examines the C (.c & .h) source files in the current directory. Cscope
may also be invoked for source files named on the command line. In either case, Cscope
searches the standard directories for the #include files that it does not find in the current
directory. Cscope uses a symbol reference cross-reference, called Cscope, out by
default,to locate functions, function calls, Macros, variables and pre-processors
symbols in the files.
• Cscope builds the symbol cross-reference for the first time it is used on the source files
for the program being browsed. On a subsequent invocation, Cscope rebuilds the cross-
reference only if a source file has changed or the list of source files is different. When
the cross-reference is re-built, the data for the unchanged files from the cross- reference
are copied, which makes rebuilding faster than the initial build.
Requesting the initial search:
After the cross-reference is ready, cscope will display this menu:
• Find this C symbol:
• Find this function definition:
• Find functions called by this function:
• Find functions calling this function:
• Find this text string:
• Change this text string:
• Find this egrep pattern:
• Find this file:
• Find files #including this file:
• Press the <Up> or <Down> keys repeatedly to move to the desired input field, type
the text to search for, and then press the <Return> key.

Issuing subsequent requests using Cscope options:


• If the search is successful, any of these single-character commands can be used:
0-9a-zA-Z
• Edit the file referenced by the given line number.
<Space>
• Display next set of matching lines.
<Tab>
• Alternate between the menu and the list of matching lines
<Up>
• Move to the previous menu item (if the cursor is in the menu) or move to the previous
matching line (if the cursor is in the matching line list.)
<Down>
• Move to the next menu item (if the cursor is in the menu) or move to the next matching
line (if the cursor is in the matching line list.)
+
• Display next set of matching lines.
-
• Display previous set of matching lines.
^e
• Edit displayed files in order.
>
• Write the displayed list of lines to a file.
>>
• Append the displayed list of lines to a file.
<
• Read lines from a file that is in symbol reference format (created by > or >>), just like the
-F option.
^
• Filter all lines through a shell command and display the resulting lines, replacing the lines
that were already there.
|
• Pipe all lines to a shell command and display them without changing them. At any time
these single-character commands can also be used:
<Return>
• Move to next input field.
^n
• Move to previous input field.
^y
• Search with the last text typed.
^b
• Move to previous input field and search pattern.
^f
• Move to next input field and search pattern.
^c
• Toggle ignore/use letter case when searching. (When ignoring letter case, search for
``FILE'' will match ``File'' and ``file''.)
^r
• Rebuild the cross-reference.
!
• Start an interactive shell (type ^d to return to cscope).
^l
• Redraw the screen.
?
• Give help information about cscope commands.
^d
• Exit Cscope.

Note:
If the first character of the text to be searched for matches one of the above commands,
escape it by typing a (backslash) first. Substituting new text for old text.
After the text to be changed has been typed, Cscope will prompt for the new text, and
then it will display the lines containing the old text. Select the lines to be changed with these
single- character commands:
0-9a-zA-Z
Mark or unmark the line to be changed.
*
Mark or unmark all displayed lines to be changed.
<Space>
Display next set of lines.
+
Display next set of lines.
-
Display previous set of lines.
a
Mark or unmark all lines to be changed.
^d
Change the marked lines and exit.
<Esc>
Exit without changing the marked lines.
!
Start an interactive shell (type ^d to return to Cscope).
^l
Redraw the screen.
?
Give help information about Cscope commands.
Special keys
If your terminal has arrow keys that work in vi, you can use them to move around the input
fields. The up-arrow key is useful to move to the previous input field instead of using the
<Tab> key repeatedly. If you have <CLEAR>, <NEXT>, or <PREV> keys they will act as the
^l, +, and - commands, respectively.
Output:
Result:
Thus, we have experimented Cscope tools with an example C program.
EX.NO: 4
CONSTRUCT CHARACTER ORIENTED DEVICE DRIVERS

DATE:

Aim:
To construct a simple character device driver program in Linux.
Description:
• The device drivers are embedded software modules that contain the functionality to
operate the individual hardware devices.
• The reason for the device driver software is to remove the need for the application to
know how to control each piece of hardware.
• Each individual device driver would typically need to know only how to control its
hardware device
• Character device drivers are used for driving sequential access devices. The amount
of data accessed is not of fixed size.
• The character device drivers are accessed by the application using the standard calls
such as open, read, write.
• The role of a driver is to provide mechanisms which allow normal users to access
protected parts of its system, in particular ports, registers and memory addresses
normally managed by the operating system.
• One of the good features of Linux is the ability to extend at runtime the set of the
features offered by the kernel. Users can add or remove functionalities to the kernel
while the system is running.
• These \programs" that can be added to the kernel at runtime are called \module" and
built into individuals with .ko (Kernel object) extension.
The Linux kernel takes advantage of the possibility to write kernel drivers as modules which
can be uploaded on request.
Commands:
Command Description

$ uname –r Returns a string naming the current system

$ ls To check object file created or not in the specified directory

$ sudo dmesg To see the message communicated by modules to the kernel

$ sudo dmesg –C To clear the communicated message


$ sudo dmesg To check message communication

$ lsmod List all the modules running in the systems

$ sudo insmod (here simpleDriverf is user defined file.. ko kernel object file)
simpleDriver.ko It inserts the simpleDriver module in the list

$ sudo rmmod To remove kernel object (now the module is removed successfully
simpleDriver.k check the command

Code:
hello.c
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
static int _init hello_start (void)
{
printk (KERN_INFO "Hello, I'm here to help\n"); return 0;
}
static void exit hello_end(void)
{
printk(KERN_INFO "Goodbye, I hope I was helpful\n");
}
module_init(hello_start);
module_exit(hello_end);

Result:
The C program is written to create Character Device Driver program and output is
verified successfully.
EX.NO: 5 A
IMPLEMENTATION OF TASK MANAGEMENT IN REAL-
TIME OPERATING SYSTEMS (RTOS) USING MICROC/OS-II
DATE:

Aim:
To develop a C program for scheduling tasks based on “Round Robin algorithm” using
FreeRTOS APIs.
Software Requirement:
• Ubuntu Linux distros
• Text editors like gedit, vi in linux with gcc
Description:
Task Priorities:
• The priority can be changed after the scheduler has been started by using the
• vTaskPrioritySet() API function.
• Priorities are defined in configMAX_PRIORITIES compile time configuration constant
within FreeRTOSConfig.h.
• Therefore, the range of available priorities is 0 to (configMAX_PRIORITIES – 1).
• The FreeRTOS scheduler will always ensure that the highest priority task that is able to
run is the task selected to enter the Running state. Where more than one task of the same
priority is able to run, the scheduler will transition each task into and out of the Running
state, in turn.
Time Measurement and the Tick Interrupt:
• Scheduling Algorithms, describes an optional feature called ‘time slicing’ to be able to
select the next task to run, the scheduler itself must execute at the end of each time slice
1.
• A periodic interrupt, called the ‘tick interrupt’, is used for this purpose.
• configTICK_RATE_HZ compile time configuration constant within
FreeRTOSConfig.h.
• configTICK_RATE_HZ is set to 100 (Hz), then the time slice will be 10 milliseconds.
The time between two tick interrupts is called the ‘tick period’. One time slice equals
one tick period.
• The optimal value for configTICK_RATE_HZ is dependent on the application being
developed, although a value of 100 is typical.
• FreeRTOS API calls always specify time in multiples of tick periods, which are often
referred to simply as ‘ticks’. The pdMS_TO_TICKS() macro converts a time specified
in milliseconds into a time specified in ticks.
TickType_t xTimeInTicks = pdMS_TO_TICKS( 200 );
Expanding the ‘Not Running’ State:
• To make the tasks useful they must be re-written to be event-driven. An event-driven
task has work (processing) to perform only after the occurrence of the event that triggers
it, and is not able to enter the Running state before that event has occurred.
• A task that is waiting for an event is said to be in the ‘Blocked’ state, which is a sub-
state of the Not Running state.
• Temporal (time-related) events—the event being either a delay period expiring, or an
absolute time being reached. For example, a task may enter the Blocked state to waitfor
10 milliseconds to pass.
• Synchronization events—where the events originate from another task or interrupt. For
example, a task may enter the Blocked state to wait for data to arrive on a queue.
Synchronization events cover a broad range of event types.
• The Suspended State Suspended’ is also a sub-state of Not Running. Tasks in the
Suspended state are not available to the scheduler. The only way into the Suspended
state is through a call to the vTaskSuspend() API function, the only way out being
through a call to the vTaskResume() or xTaskResumeFromISR() API functions.
• The Ready State Tasks that are in the Not Running state but are not Blocked or
Suspended are said to be in the Ready state. They are able to run, and therefore ‘ready’
to run, but are not currently in the Running state.

• vTaskDelay() places the calling task into the Blocked state for a fixed number of tick interrupts.
void vTaskDelay( TickType_t xTicksToDelay );
• vTaskDelay( pdMS_TO_TICKS( 100 ) ) will result in the calling task remaining in the Blocked state
for 100 milliseconds.
The vTaskDelayUntil() API Function
• The parameters to vTaskDelayUntil() specify, instead, the exact tick count value at
which the calling task should be moved from the Blocked state into the Ready state.
• vTaskDelayUntil() is the API function that should be used when a fixed execution
period is required (where you want your task to execute periodically with a fixed
frequency), as the time at which the calling task is unblocked is absolute, rather than
relative to when the function was called (as is the case with vTaskDelay()).
• void vTaskDelayUntil( TickType_t * pxPreviousWakeTime, TickType_t
xTimeIncrement );
• pxPreviousWakeTime : This parameter is named on the assumption that
vTaskDelayUntil() is being used to implement a task that executes periodically and with
a fixed frequency. In this case, pxPreviousWakeTime holds the time at which the task
last left the Blocked state (was ‘woken’ up). This time is used as a reference point to
calculate the time at which the task should next leave the Blocked state.
• xTimeIncrement This parameter is also named on the assumption that
vTaskDelayUntil() is being used to implement a task that executes periodically and with
a fixed frequency—the frequency being set by the xTimeIncrement value.
• The xLastWakeTime variable needs to be initialized with the current tick count. Note
that this is the only time the variable is explicitly written to. After this xLastWakeTime
is managed automatically by the vTaskDelayUntil() API function.

The Idle Task and the Idle Task Hook


There must always be at least one task that can enter the Running state. To ensure this
is the case, an Idle task is automatically created by the scheduler when vTaskStartScheduler()
is called.
• The idle task has the lowest possible priority (priority zero), to ensure it never prevents
a higher priority application task from entering the Running state.
Idle Task Hook Functions
• To add application specific functionality directly into the idle task through the use of an
idle hook (or idle callback) function—a function that is called automatically by the idle
task once per iteration of the idle task loop.
• Placing the processor into a low power mode.
• An Idle task hook function must never attempt to block or suspend.
• Idle task is responsible for cleaning up kernel resources after a task has been deleted. If
the idle task remains permanently in the Idle hook function, then this clean-up cannot
occur.
void vApplicationIdleHook( void );
Program:
// Task Scheduling using Round Robin algorithm
#include <stdio.h>
#include <stdlib.h>
#include <FreeRTOS.h>
#include <task.h>
#include <timers.h>
#define TASKSCHEDULER
#ifdef TASKSCHEDULER
void vTask1(void*);
void vTask2(void*);
void vTask3(void*);
void vTask4(void*);
#endif
void vApplicationIdleHook(void); int main(void)
{
#ifdef TASKSCHEDULER
xTaskCreate( vTask1, "Task 1", 1000, NULL, 1, NULL );
xTaskCreate( vTask2, "Task 2", 1000, NULL, 1, NULL );
xTaskCreate( vTask3, "Task 3", 1000, NULL, 1, NULL );
xTaskCreate( vTask4, "Task 4", 1000, NULL, 1, NULL ); #endif
vTaskStartScheduler();
return 0;
}
void vAssertCalled( unsigned long ulLine, const char * const pcFileName )
{
taskENTER_CRITICAL();
{
printf("[ASSERT] %s:%lu\n", pcFileName, ulLine); fflush(stdout);
}
taskEXIT_CRITICAL();
exit(-1);
}
#ifdef TASKSCHEDULER
void vTask1(void* parameter)
{
while(1)
{
printf("Task 1\n");
vTaskDelay(pdMS_TO_TICKS(250));
}
}
void vTask2(void* parameter)
{
while(1)
{
printf("Task 2\n"); vTaskDelay(pdMS_TO_TICKS(250));
}
}
void vTask3(void* parameter)
{
TickType_t xLastWaketime = xTaskGetTickCount(); while(1)
{
printf("Task 3 with 250ms\n");
vTaskDelayUntil(&xLastWaketime, pdMS_TO_TICKS(250));
}
}
void vTask4(void* parameter)
{
TickType_t xLastWaketime = xTaskGetTickCount();
while(1)
{
printf("Task 4 with 500ms\n");
vTaskDelayUntil(&xLastWaketime, pdMS_TO_TICKS(500));
}
}
#endif
void vApplicationIdleHook(void)
{
// printf("Idle\r\n");
}
Steps to run the program:
• Install the dependencies for Ubuntu
sudo apt-get install libcs6-dev-i386
• Navigate to the C source code
$cd Project/main.c
• Compile the Makefile using make command
$make
Output:

Result:
Thus, tasks were created and scheduled based on “Round Robin algorithm” using
FreeRTOS APIs and the output is verified successfully.
EX.NO: 6 A
DEVELOPMENT OF BLUETOOTH INTERFACING USING
MSP430 LAUNCHPAD
DATE:

Aim:
To write a sketch program to connect the Bluetooth Module with MSP430G2553 to
control a LED.

Apparatus Required:
• MSP430G2553 Launchpad
• Energia IDE
• HC-05 Bluetooth module.

Procedure:
• Attach the MSP430G2553 board with the system.
• Attach the Bluetooth Module with MSP430G2553 board.
• Double click on Energia IDE on the desktop.
• Select the board type as MSP430G2553 Launchpad from Tool.
• Create a new program on Energia IDE and save it.
• Compile the program and upload it to the MSP430G2553 Launchpad board.
• Run the program and verify the output by controlling the LED using an Android
application on mobile.

Program:
#define LED RED_LED
void setup()
{
Serial.begin(9600);
pinMode(2, OUTPUT);
}
void loop()
{
if (Serial.available())
{
char data_received;
data_received = Serial.read();
if (data_received == '1')
{
digitalWrite(LED, HIGH);
Serial.write("LED turned ON\n");
}
if (data_received == '2')
{
digitalWrite(LED, LOW);
Serial.write("LED turned OFF\n");
}
}
}

Output:

Result:
Thus, the sketch program to connect the Bluetooth Module with MSP430G2553 to
control a led was implemented successfully.
EX.NO: 6 B
DEVELOPMENT OF ESP8266 INTERFACING (WIFI) USING
MSP430 LAUNCHPAD
DATE:

Aim:
To write a sketch program to connect the ESP8266 WiFi Module with MSP430G2553
to send a data to browser.

Apparatus Required:
• MSP430G2553 Launchpad
• Energia IDE
• ESP8266 WiFi module.

Procedure:
• Attach the MSP430G2553 board with the system.
• Attach the WiFi Module with MSP430G2553 board.
• Double click on Energia IDE on the desktop.
• Select the board type as MSP430G2553 Launchpad from Tool.
• Create a new program on Energia IDE and save it.
• Compile the program and upload it to the MSP430G2553 Launchpad board.
• Run the program and verify the output by sending data to browser.
Program:
#define SSID "RAGHAV"
#define PASS "12345678"
#define DST_IP "things.ubidots.com"
#define idvariable "569fc4ba76254229c49896a6"
int len;

void setup()
{
// Open serial communications and wait for port to open:
char cmd[254];
Serial.begin(9600);
Serial.setTimeout(5000);
//test if the module is ready
Serial.println("AT+RST");
delay(1000);
if (Serial.find("ready"))
{
Serial.println("Module is ready");
}
else
{
Serial.println("Module have no response.");
while (1);
}
delay (1000);
//connect to the wifi
boolean connected = false;
for (int i = 0; i < 5; i++)
{
if (connectWiFi())
{
connected = true;
break;
}
}
if (!connected) {
while (1);
}
delay(5000);
Serial.println("AT+CIPMUX=0");
}

void loop()
{
int value = analogRead(A0); //you can change ir to another pin
int num=0;
String var = "{\"value\":"+ String(value) + "}";
num = var.length();
String cmd = "AT+CIPSTART=\"TCP\",\"";
cmd += DST_IP;
cmd += "\",80";
Serial.println(cmd);
if (Serial.find("Error"))
return;
len=strlen ("POST /api/v1.6/datasources/");
len=len+strlen (idvariable);
len=len+strlen ("/values HTTP/1.1\nContent-Type: application/json\nContent-Length:
");
char numlength[4]; // this will hold the length of num which is the length of the JSON
element
sprintf(numlength, "%d", num); // saw this clever code off the net; works yay
len=len+strlen (numlength);
len=len + num; //fixed length of the string that will print as Content-Length: in the
POST
len=len+strlen ("\nX-Auth-Token: ");
len=len+strlen (token);
len=len+strlen ("\nHost: things.ubidots.com\n\n");
len=len+strlen ("\n\n");
Serial.print("AT+CIPSEND=");
Serial.println (len); //length of the entire data POST for the CIPSEND command of
ESP2866
//Serial.println(cmd.length());
if (Serial.find(">"))
{
//Serial.print(">");
}
else
{
Serial.println("AT+CIPCLOSE");
delay(1000);
return;
}
Serial.print ("POST /api/v1.6/variables/");
Serial.print (idvariable);
Serial.print ("/values HTTP/1.1\nContent-Type: application/json\nContent-Length: ");
Serial.print (num);
Serial.print ("\nX-Auth-Token: ");
Serial.print (token);
Serial.print ("\nHost: things.ubidots.com\n\n");
Serial.print (var);
Serial.println ("\n\n");
delay(9000);
//Serial.find("+IPD"); clear the input buffer after the web site responds to the POST
while (Serial.available())
{
char c = Serial.read();
}
delay(1000);
}
boolean connectWiFi()
{
Serial.println("AT+CWMODE=1");
String cmd = "AT+CWJAP=\"";
cmd += SSID;
cmd += "\",\"";
cmd += PASS;
cmd += "\"";
Serial.println(cmd);
delay(2000);
if (Serial.find("OK"))
{
return true;
}
else
{
return false;
}
}

Output:

Result:
Thus, the sketch program to connect a ESP8266 Wifi Module with MSP430G2553 to
send a data to browser was implemented successfully.
EX.NO: 7
DEVELOPMENT OF EMBEDDED APPLICATIONS USING TI
CC3200 LAUNCHPAD
DATE:

Aim:
To write a CC3200 sketch for blinking (ON/OFF) of inbuilt LED using CC3200.

Apparatus Required:
• Energia IDE
• CC3200 board
• LED
• Bread board
• 220 ohm resistor
• Jumper wires

Procedure:
• Attach the CC3200 board with the system.
• Interface LED circuit with CC3200 board.
• Double click on Energia on the desktop.
• Select the board type as CC3200 from Tools-Board and also select COM port number
from the PORT option
• Create a new program in the Energia IDE software and save it.
• Compile the program and upload it to the CC3200 board.
• Run the program and verify the output.

Code:
For Single LED Bulb:
#define LED 5
void setup()
{
pinMode(LED,OUTPUT);
}
void loop()
{
digitalWrite(LED, HIGH);
delay(1000):
digitalWrite(LED,LOW);
delay(1000);
}
For Multiple LED Bulb:
#define RLED 9
#define GLED 10
#define YLED 29
void setup()
{
pinMode(RLED,OUTPUT);
pinMode(GLED,OUTPUT);
pinMode(YLED,OUTPUT);
}
void loop()
{
digitalWrite(RLED, HIGH);
digitalWrite(GLED, HIGH);
digitalWrite(YLED, HIGH);
delay(1000):
digitalWrite(RLED,LOW);
digitalWrite(GLED,LOW);
digitalWrite(YLED,LOW);
delay(1000);
}

Output:

Result:
Thus, the Energia sketch to ON/OFF of built-in LEDs was executed successfully.
EX.NO: 8
DESIGN OF IOT APPLICATIONS WITH SENSORS USING TI
CC3200 LAUNCHPAD
DATE:

Aim:
To write a program in Energia to check whether any live object traces are present by
using PIR Sensor using CC3200.
Apparatus Required:
• Energia IDE
• CC3200 Board
• LED
• PIR Sensor
• Breadboard
Procedure:
• Attach the CC3200 board to the system.
• Connect the PIR sensor with the digital pin of the CC3200 board.
• Double-click on Energia on the desktop.
• Select the board type as CC3200 from Tools-Board and also select the COM port number
from the PORT option.
• Create a new program in the Energia software and save it.
• Compile the program and upload it to the CC3200 board.
• Run the program and verify the output.
Program:
int pir=4;
int val = LOW;
void setup()
{
pinMode(pir, INPUT);
Serial.begin(9600);
}
void loop() {
val = digitalRead(pir);
if (val = = HIGH)
{
Serial.println(“Motion Detected”);
}
else
{
Serial.println(“Motion NOT Detected”);
}
}
Output:

Result:
Thus, the Energia sketch to interface the PIR sensor with CC3200 was executed and
the output was verified successfully.

You might also like