Devi Ahilya Vishwavidyalaya, Indore: School of Electronics
Devi Ahilya Vishwavidyalaya, Indore: School of Electronics
Submitted to:-
Ms.Kirti panwar bhati
Master of Technology (Embedded Systems)
Batch 2020-25
EMBEDDED MICROCONTROLLER LAB FILE
Index
Sr.
Name of the Program Date Sign
No.
1.
Headless setup for Raspberry PI
2.
Configure Static IP for Raspberry PI
3.
Controlling Raspberry PI using GUI
4.
Controlling Raspberry PI using telegram
16.
Arduino program for Sound Sensor.
Program 1 :-
Block Diagram:-
Code:
Output:
Program 2 :-
3 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE
Block Diagram:-
Code:
Output:
Program 3 :-
4 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE
label_1.grid(row=0, column=0)
exitButton.grid(row = 1 ,column = 0)
ledButton.grid(row = 1 ,column = 1)
root.bind("<Escape>", end_fullscreen)
root.mainloop() # starts the GUI loop
Output:
Program 4 :-
-> Controlling Raspberry PI using telegram
GPIO.setmode(GPIO.BOARD)
#setupGPIOoutputchannel
GPIO.setup(11,GPIO.OUT)
def handle(msg):
print msg
chat_id= msg ['chat'] ['id']
print chat_id command = msg ['text']
print 'Gotcommand:%s' %command
if command == 'on':
bot.sendMessage(chat_id, "set led on")
on(11)
elif command =='off':
bot.sendMessage(chat_id, "set led off")
off(11)
bot=telepot.Bot(“5971834468:AAHo5vKznwoBf0C1lBiaMhNM-qADK-
pNY3E”)
MessageLoop(bot,handle).run_as_thread()
print ' I am listening...'
while1:
time.sleep(10)
Output:
Program 5 :-
->Create NodeRed flow and dashboard for controlling the equipment in two
different rooms.
Hardware and Software Requirement:-
Block Diagram:-
Code:
Output:
Program 6 :-
->Show R-Pi CPU temperature on NodeRed flow.
Block Diagram:-
Code:
Output:
Program 7 :-
->Create mosquito client – install its server and create two client one for
publisher and one for subscriber.
Hardware and Software Requirement:-
10 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE
Block Diagram:-
Code:
Output:
Program 8:-
->Create the publisher and subscriber on IOT MQTT panel and communicate
with HIVEMQTT broker and its websocket.
Hardware and Software Requirement:-
11 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE
HiveMQ broker,
IoT MQTT mobile application
Code:
Output:
Program 9 :-
->Use python Q3 android application for accessing various component on
mobile phone.
Output:
Code:
Q2:Enable Bluetooth
import androidhelper
import time
droid = androidhelper.Android()
droid.toggleBluetoothState(True)
droid.dialogCreateAlert('Be a server?')
droid.dialogSetPositiveButtonText('Yes')
droid.dialogSetNegativeButtonText('No')
droid.dialogShow()
result = droid.dialogGetResponse()
is_server = result.result['which'] == 'positive'
if is_server:
droid.bluetoothMakeDiscoverable()
droid.bluetoothAccept()
else:
droid.bluetoothConnect()
if is_server:
result = droid.getInput('Chat', 'Enter a message').result
if result is None:
droid.exit()
droid.bluetoothWrite(result + '\n')
while True:
message = droid.bluetoothReadLine().result
droid.dialogCreateAlert('Chat Received', message)
droid.dialogSetPositiveButtonText('Ok')
droid.dialogShow()
droid.dialogGetResponse()
result = droid.getInput('Chat', 'Enter a message').result
if result is None:
break
droid.bluetoothWrite(result + '\n')
droid.exit()
Output:
Program 10 :-
->Create a database “Student” with Roll-No.(auto-increment),”
Name”,”AGE”,” percentage”.
Block Diagram:-
Code:
Output:
Program 11. :-
->Arduino program for LED.
Code:
#define LED 2 //connect LED to digital pin2
void setup() {
// initialize the digital pin2 as an output.
pinMode(LED, OUTPUT);
}
void loop() {
digitalWrite(LED, HIGH); // set the LED on
delay(1000); // for 500ms
digitalWrite(LED, LOW); // set the LED off
delay(1000);
}
Output:
Program 12 :-
->Arduino program for buzzer when you press a button.
Code:
const int buttonPin = 2;
const int buzzer = A3;
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(buzzer, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
19 | Page M.Tech.(ES) Sem-VI
EMBEDDED MICROCONTROLLER LAB FILE
if (buttonState == HIGH) {
tone(buzzer, 1000);
}
else {
noTone(buzzer);
}
}
Output:
Program 13 :-
->Arduino LED program using touch sensor.
Hardware and Software Requirement:-
Connecting wires, Arduino UNO, Arduino Uno Base shield, Touch sensor,
Code:
const int TouchPin=2;
const int ledPin=3;
void setup() {
pinMode(TouchPin, INPUT);
pinMode(ledPin,OUTPUT);
}
void loop() {
int sensorValue = digitalRead(TouchPin);
if(sensorValue==1)
{
digitalWrite(ledPin,HIGH);
}
else
{
digitalWrite(ledPin,LOW);
}
}
Output:
Program 14 :-
->Arduino program for Rotary angle sensor.
Code:
#define ROTARY_ANGLE_SENSOR A0
#define LED 3 //the Grove - LED is connected to PWM pin D3 of Arduino
#define ADC_REF 5 //reference voltage of ADC is 5v.If the Vcc switch on the
seeeduino
//board switches to 3V3, the ADC_REF should be 3.3
#define GROVE_VCC 5 //VCC of the grove interface is normally 5v
#define FULL_ANGLE 300 //full value of the rotary angle is 300 degrees
void setup()
{
Serial.begin(9600);
pinMode(ROTARY_ANGLE_SENSOR, INPUT);
pinMode(LED,OUTPUT);
}
void loop()
{
float voltage;
int sensor_value = analogRead(ROTARY_ANGLE_SENSOR);
voltage = (float)sensor_value*ADC_REF/1023;
float degrees = (voltage*FULL_ANGLE)/GROVE_VCC;
Serial.println("The angle between the mark and the starting position:");
Serial.println(degrees);
int brightness;
brightness = map(degrees, 0, FULL_ANGLE, 0, 255);
analogWrite(LED,brightness);
delay(1000);
}
Output:
Program 15 :-
->Arduino program for Light sensor.
Code:
const int pinLight = A0;
const int pinLed = 7;
// Defines the light-sensor threshold value below which the LED will turn on.
// Decrease this value to make the device more sensitive to ambient light, or
vice-versa.
int thresholdvalue = 50;
void setup()
{
Serial.begin(9600);
// Configure the LED's pin for output signals.
pinMode(pinLed, OUTPUT);
}
void loop()
{
// Read the value of the light sensor. The light sensor is an analog sensor.
int sensorValue = analogRead(pinLight);
Serial.println(sensorValue);
// Turn the LED on if the sensor value is below the threshold.
if(sensorValue < thresholdvalue)
{
digitalWrite(pinLed, HIGH);
}
else
{
digitalWrite(pinLed, LOW);
}
}
Output:
Program 16 :-
->Arduino program for Sound Sensor.
Hardware and Software Requirement:-
Connecting wires, Arduino UNO, Ardui0no Uno Base shield, Sound Sensor,
Arduino desktop software.
Block Diagram:-
Code:
// Define the pins to which the sound sensor
// and LED are connected.
const int pinSound = A0;
const int pinLed = 7;
// Define the sound level above which to turn //on the LED.
// Change this to a larger value to require a
// louder noise level.
int thresholdValue = 400;
void setup()
{
// Configure LED's pin for output signals.
pinMode(pinLed, OUTPUT);
}
void loop()
{
// Read the value of the sound sensor.
// If the measured sound level is above the //threshold, blink the LED.
if(sensorValue > thresholdValue)
{
// Turn the LED on for 200ms, then turn it //back off.
digitalWrite(pinLed,HIGH);
delay(200);
digitalWrite(pinLed,LOW);
}
}
Output:
Program 17 :-
->Arduino program for temperature sensor.
Block Diagram:-
Code:
// Demo of Grove - Starter Kit V2.0
void setup()
{
// Configure the serial communication line at 9600 baud (bits per second.)
Serial.begin(9600);
}
void loop()
{
// Get the (raw) value of the temperature sensor.
int val = analogRead(pinTemp);
Output: