1 | P a g e PRACTICAL NO. 01 Aim: Displaying single LED. Hardware Requirements: 1. R aspberry Pi Model A/B/B+ / Arduin o 2.LED 3. Breadboard 4. Jumper wires 5.Register Code: void setup(){ pinMode (13,OUTPUT); } void loop(){ digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(1000); } 2 | P a g e Complete connection : Output: 3 | P a g e PRACTICAL NO. 02 Aim: Displaying different LED pattern with Raspbe rry Pi. Hardware Requirements: 1. Ras pberry Pi Model A/B/B+ /Ardunio 2.LED 3. Breadboard 4. Jumper wires 5.Register Code: //C++code voidsetup() { pinMode(1,OUTPUT); pinMode(2,OUTPUT); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMod e(5,OUTPUT); pinMode(6,OUTPUT); } voidloop() { digitalWrite(1,HIGH); delay(1000);//Waitfor1000milli second(s) digitalWrite(1, LOW); delay(1000);//Waitfor1000millis econd(s) digitalWrite(2, HIGH); delay(1000);//Waitfor1000milli second(s) digitalWrite(2, LOW); delay(1000);//Waitfor1000millisecond(s) digital Write(3, HIGH); delay(1000);//Waitfor1000milli second(s) digitalWrite(3, LOW); delay(1000);//Waitfor1000millis econd(s) digitalWrite(4, HIGH); 4 | P a g e delay(1000);//Waitfor1000milli second(s) digitalWrite(4, LOW); delay(1000);//Waitfor1000millis econd(s) digitalWrite( 5, HIGH); delay(1000);//Waitfor1000milli second(s) digitalWrite(5, LOW); delay(1000);//Waitfor1000millis econd(s) digitalWrite(6, HIGH); delay(1000);//Waitfor1000milli second(s) digitalWrite(6, LOW); delay(10 00);//Waitfor1000millisecond(s) } Complete Connection: Output: 5 | P a g e Practical No .03 Aim: Displaying Time over4 - Digit 7 - segment display using Raspberry Pi/Arduino. Hardware Requirements: 1. Raspberry Pi Model A/B/B+/Arduino 2. 4digit 7 segment Display. 3. Jumper wires(Female to Female) Software Requirements: 1. Raspbian Stretch OS/TinkerCad Code: chara=2; charb=3; charc=4; chard=5; chare=6; char f=7; char g=8; chardigit1=13; chardigit2=12; chardigit3=11; chardigit4=10; charNumber[10]={ 0b1111110, //0 0b0110000, //1 0b1101101, //2 0b1111001, //3 0b0110011, //4 0b1011011, //5 6 | P a g e 0b1011111, //6 0b1110000, //7 0b1111111, //8 0b1111011, //9 }; voiddisplay(intn) { digitalWrite(a,Number[n]&0b1000000); digitalWrite(b,Number[n]&0b0100000); digitalWrite(c,Number[n]&0b0010000); digitalWrite(d,Number[n]&0b0 001000); digitalWrite(e,Number[n]&0b0000100); digitalWrite(f,Number[n] & 0b0000010); digitalWrite(g,Number[n]&0b0000001); } voidsetup() { pinMode(a, OUTPUT); pinMode(b, OUTPUT); pinMode(c, OUTPUT); pinMode(d, OUTPUT); pinMode(e, OUTPUT); pinMode(f, OUTPUT ); pinMode(g, OUTPUT); pinMode(digit1,OUTPUT); pinMode(digit2,OUTPUT); pinMode(digit3,OUTPUT); pinMode(digit4,OUTPUT); } voidloop() { display(7); } 7 | P a g e Complete Connection: Output: 8 | P a g e Practical No. 04 Aim: Interfacing16X2LCDtoDisplaymessages. Hardware Requirements: 1. Arduino 2.LCD 3. Breadboard 4. Jumper wires Code: //C++code #include <Adafruit_LiquidCrystal.h>Adafruit_LiquidCrystal lcd_1(0); void setup() { lcd_1.begin(16,2); } voidloop() { lcd_1.setCursor(5,1); lcd_1.print("helloworld"); lcd_1.setCursor(5, 0); lcd_1.print("loadprint"); delay(10);//Delayalittlebittoimprovesimulationperformance } 9 | P a g e Complete Connection: Output: 10 | P a g e PRACTICAL NO. 05 Aim: Raspberry Pi Based Oscilloscope. Hardware Requirements: 1. Raspberry Pi Model A/B/B+ 2. DS1115 ADC 3. Breadboard 4. Jumper wires Software Requirements: 1. Raspbian stretch OS 2. Adafruit module for interfacing with the ADS1115 ADC chip 3. Python Module matplotlib used for data visualization. Code: importmatplotlib.pyplot as plt fr ommatplotlib.animation import FuncAnimation import Adafruit_ADS1x15 import time importmatplotlib.pyplot as plt #import numpy fromdrawnow import * # Import the ADS1x15 module. import Adafruit_ADS1x15 # Create an ADS1115 ADC (16 - bit) instance. 11 | P a g e adc = Adafruit _ADS1x15.ADS1115() GAIN = 1 val = [ ] cnt = 0 plt.ion() # Start continuous ADC conversions on channel 0 using the previous gain value. adc.start_adc(0, gain=GAIN) print('Reading ADS1x15 channel 0') #create the figure function defmakeFig(): plt.ylim( - 5000,5000) plt.title('Osciloscope') plt.grid(True) plt.ylabel('ADC outputs') plt.plot(val, 'ro - ', label='Channel 0') plt.legend(loc='lower right') while (True): # Read the last ADC conversion value and print it out. value = adc.get_last_result() print ('Channel 0: {0}'.format(value)) # Sleep for half a second. time.sleep(0.5) val.append(int(value)) drawnow(makeFig) 12 | P a g e plt.pause(.000001) cnt = cnt+1 if(cnt>50): val.pop(0) #Create an ADS1115 ADC(16 - bit) inatance adc = Adafruit_ADS1x15.ADS1115() GAIN = 1 val = [] # Start continuous ADC conversions on channel 0 using the previous gain value adc.start_adc(0,gain=GAIN) print('Reading ADS1x15 channel 0') fig,ax = plt.subplots() axax.set_ylabe('ADC outputs') line,=ax.plot([], 'ro - ',lable='Channel 0') ax.legend(loc='lower right') def update(cnt): # Read the last ADC conversion value and print it out value = adc.get_last_result() print('Channel 0:{0}'.format (value)) line.set_data(list(range(len(val))),val) 13 | P a g e ax.relim() ax.autoscale_view() val.append( int(value)) if(cnt>50): val.pop(0) ani=FuncAnimation(fig,update,interval=500) plt.show() STEP 01 - > STEP 02 - > STEP 03 - > STEP 04 - > 14 | P a g e STEP 05 - > STEP 06 - > Output: 15 | P a g e 16 | P a g e PRACTICAL NO. 06 Aim: Controlling Raspberry Pi with Telegram. Hardware Requirements: 1. Raspberry Pi Model A/B/B+ 2.LED 3. Breadboard 4. Jumper wires Code: import time, datetime importRPi.GPIO as GPIO importtelepot fromtelepot.loop import MessageLoop green = 6 yellow = 19 re d = 13 blue = 26 now = datetime.datetime.now() GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) ##LED Blue 17 | P a g e GPIO.setup(blue, GPIO.OUT) GPIO.output(blue, 0) #Off initially #LED Yellow GPIO.setup(yellow, GPIO.OUT) GPIO.output(yellow, 0) #Off initially #LED Red GPIO.setup(red, GPIO.OUT) GPIO.output(red, 0) #Off initially #LED green GPIO.setup(green, GPIO.OUT) GPIO.output(green, 0) #Off initially def action(msg): chat_id = msg['chat']['id'] command = msg['text'] print ('Received: %s' % command) if 'on' in c ommand: message = "on" if 'blue' in command: message = message + "blue " GPIO.output(blue, 1) if 'yellow' in command: 18 | P a g e message = message + "yellow " GPIO.output(yellow, 1) if 'red' in command: message = message + "red " GPIO.output(red, 1) if 'green' in command: message = message + "green " GPIO.output(green, 1) if 'all' in command: message = message + "all " GPIO.output(blue, 1) GPIO.output(yellow, 1) GPIO.output(red, 1) GPIO.output(green, 1) message = message + "light(s)" telegram_bot.sendMe ssage (chat_id, message) if 'off' in command: message = "off " if 'blue' in command: message = message + "blue " GPIO.output(blue, 0) if 'yellow' in command: message = message + "yellow " GPIO.output(yellow, 0) 19 | P a g e if 'red' in command: message = message + "red " GPIO.output(red, 0) if 'green' in command: message = message + "green " GPIO.output(green, 0) if 'all' in command: message = message + "all " GPIO.output(blue, 0) GPIO.output(yellow, 0) GPIO.output(red, 0) GPIO.output(green, 0) message = message + "light(s)" telegram_bot.sendMessage (chat_id, message) telegram_bot =telepot.Bot('618143410:AAGQ_7ekijbzSK8aVAmAEmK9jjNl0_5g - Ck') print (telegram_bot.getMe()) MessageLoop(telegram_bot, action).run_as_thread() print ('Up and Running....') whil e 1: time.sleep(10) 20 | P a g e Instructions: • Install Telegram app on your Smart Phone from Playstore. • Open Telegram. • Request the Bot Father to create a new Bot. • Search “BotFather” and Click on Start. • Create new bot using /newbot • Provide a Name for your Bot(e.g.msdtyit) • Then, Provide username for your - Bot Must be end in “bot” (e.g.msdtyit_bot) • After this process the BotFather will give you a Token for access.