res

Display LED in Pattern

 

Pin Diagram:

Name Pin number
GPIO 40
GPIO 37
GPIO 35
GPIO 33
GND 6

 

Step 1:connect the led’s using the pin connection table

Step 2:open the terminal

Step 3:open the file

Sudonano led.py

Step 4:write the code

import time

importRPi.GPIO as GPIO

GPIO.setmode(GPIO.BOARD)

GPIO.setwarnings(False)

GPIO.setup(37,GPIO.OUT)

GPIO.setup(35,GPIO.OUT)

GPIO.setup(33,GPIO.OUT)

GPIO.setup(31,GPIO.OUT)

while True:

            GPIO.output(37,True)

            GPIO.output(35,True)

            GPIO.output(33,True)

            GPIO.output(31,False)

            time.sleep(1)

            GPIO.output(37,False)

GPIO.output(35,True)

GPIO.output(33,True)

GPIO.output(31,True)

time.sleep(1)

            GPIO.output(37,True)

GPIO.output(35,False)

GPIO.output(33,True)

GPIO.output(31,True)

time.sleep(1)

            GPIO.output(37,True)

GPIO.output(35,True)

GPIO.output(33,False)

GPIO.output(31,True)

time.sleep(1)

step 5:Run the code

sudo  python led.py

Displaying Time over 4-Digit 7-Segment Display using Raspberry Pi

 

Pin diagram

 

Name Pin number
VCC 2
GND 6
DIN 38
CLK 40

 

 

step 1 :  download the zip file form the link

https://github.com/timwaizenegger/raspberrypi-examples/tree/master/actor-led-7segment-4numbers

 

step 2 : extract the zip file to the desktop

step 3 : open terminal

step 4 :cd Desktop/

step 5 : cd actor-led-7segment-4numbers/

step 6 :sudo python clock.py

 

code for clock.py

#!/usr/bin/env python

# -*- coding: utf-8 -*-

 

from time import sleep

import tm1637

 

try:

import thread

exceptImportError:

import _thread as thread

 

# Initialize the clock (GND, VCC=3.3V, Example Pins are DIO-20 and CLK21)

Display = tm1637.TM1637(CLK=21, DIO=20, brightness=1.0)

 

try:

print “Starting clock in the background (press CTRL + C to stop):”

Display.StartClock(military_time=False)

print ‘Continue Python script and tweak Display!’

sleep(5)

Display.ShowDoublepoint(False)

sleep(5)

loops = 3

while loops > 0:

fori in range(0, 10):

Display.SetBrightness(i / 10.0)

sleep(0.5)

loops -= 1

Display.StopClock()

thread.interrupt_main()

exceptKeyboardInterrupt:

print “Properly closing the clock and open GPIO pins”

Display.cleanup()

 

 

oscilloscope program

pin connection

vcc -17

gnd – 9

scl – 5

sda – 3

sudo raspi -config

(enable i2c)

sudo apt-get install build-essential python-dev python -smbus git

 

gitclonedownloAD

Raspberry Pi Based Oscilloscope

https://circuitdigest.com/microcontroller-projects/raspberry-pi-based-oscilloscope

https://github.com/adafruit/Adafruit_Python_ADS1x15

 

Name Pin number
VDD 2
GND 6
SDA 3
SCL 5

 

Step 1: Enable Raspberry Pi I2C interface

sudoraspi-config

Step 2: Install the Adafruit ADS1115 library for ADC

sudo apt-get install build-essential python-dev python-smbus git

step 3 : download the Adafruit ADS fzip from git hub

https://github.com/adafruit/Adafruit_Python_ADS1x15.git

step 4 : Extact the file to desktop

step 5 : change the directory

cd Desktop\

cd Adafruit_Python_ADS1x15-master\

sudo python setup.py install

step 6 : Test the library and 12C communication.

cd examples

python simpletest.py

 

Step 6: Install Matplotlib

sudo apt-get install python-matplotlib

sudo apt-get install python-pip

sudo pip install drawnow

sudonano scope.py

 

code for scope.py

import time

importmatplotlib.pyplot as plt

#import numpy

fromdrawnow import *

# Import the ADS1x15 module.

import Adafruit_ADS1x15

# Create an ADS1115 ADC (16-bit) instance.

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)

plt.pause(.000001)

cnt = cnt+1

if(cnt>50):

val.pop(0)

 

step 7 : save and exit the file

step 8 : run the scope.py

sudo python scope.py

 

 

 

 

 

telegram progam

big +ve- 11

small -nv – 6

 

copy the code and paste into paython

sudo pip install telepot

sudo python tel.py

 

 

Controlling Raspberry Pi with Telegram

https://www.hackster.io/Salmanfarisvp/telegram-bot-with-raspberry-pi-f373da

Step 1 : Open Telegram app in your system or mobile

Step 2 : Start “BotFather”

Step 3 : Open “BotFather”

Step 4 : Create a new Bot

/new bot

Username :AbhiTyit

Bot name :AbhiTyit_bot

You will get the token number hightlighted there in given below picture


Step 5 : come to raspberry Pi

Step 6 : open terminal

Step 7 : install telepot

sudo pip install telepot

step 8 : copy the code from the link

git clone https://github.com/salmanfarisvp/TelegramBot.git

step 9 : open the python file

sudonano telegrambot.py

step 10 : copy ur bot token in the line

bot = telepot.Bot(‘Bot Token’)

step 11 : save the file and exit

step 12 :connect the led to the pi

 

Name Pin Number
3.3V 11
GND 6

 

step 13: run the python file

sudo python telegrambot.py

step 14 : send you command through your bot

 

 

GPS Module

Pin Diagram:

Gps module pin Usb port
+5v vcc
GND GND
RX TX
TX RX

Step 1:sudo apt-get update

Step  2:sudo apt-get install gpsdgpsd-clients python-gps

Step 3:sudosystemctl start gpsd.socket

Step 4:cgps -s

 

Home Automation

Pin Connection:-

Name Pin number
GPIO 17
GND 6

 

Step 1:update the raspberry Pi

sudo apt-get update

sudo apt-get upgrade

sudo reboot

Step 2:Make sure you are in home directory using;

cd~

Step 3:Use wget to get the file from their sourceforpage

wgethttp://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz

Step 4:When download is done, extract the file and go into the directory

tarxvzf WebIOPi-0.7.1.tar.gz

cd WebIOPi-0.7.1/

Step 5:  install a patch as this version of the WebIOPi

wget https://raw.githubusercontent.com/doublebind/raspi/master/webiopi-pi2bplus.patch

patch -p1 -i webiopi-pi2bplus.patch

Step 6:  we can run the setup installation for the WebIOPi

sudo ./setup.sh

Step 7:  reboot your pi

sudo reboot

Step 8:  test our WebIOPi installation

sudowebiopi -d -c /etc/webiopi/config

Step 9:web browser connected to the raspberry pi using

 

http://raspberrypi.mshome.net:8000 or http;//thepi’sIPaddress:8000.The system will prompt you for username and password.

 

Username is webiopi

Password is raspberry

Step 10:  click on the GPIO header link.

Step 11: For this test, we will be connecting an LED to GPIO 17, so go on and set GPIO 17 as an output.

 

 

Pi  Camera

Components:

1* Raspberry Pi 3

1* Camera

Jumper wires

Step 1:enable the camera

sudoraspi-config

Step 2:install camera module

sudo apt-get update

sudo apt-get install python-picamera

Step 3:code for capture img

raspistill -o filename.jpg

Connection:

 

 

 

 

 

LED Matrix

Components :

1-RaspberryPi3

2-8x8matrix

3 –Jumper wires

Pin Connection:

Name Pin number Rpi Pin
VCC 1 2
GND 2 6
DIN 3 19
CS 4 24
CLK 5 23

Step1: git clone https://github.com/rm-hull/max7219.git

Step2: sudo python max7219/setup.py install

Step3: enable SPI

sudoraspi-config

 

Step4: install module of 8×8 matrix

Sudo apt-get install python-dev python-pip

Sudo pip install max7219

Step 5:open the terminal

Step 6:open new file

Sudonano matrix.py

Step 7:write the  program

Import max7219.led as led

device=led.matrix(cascaded=3)

device.show_message(“Akshay”)

step 8: Run the program

sudo  python matrix.py

LCD Display

Circuit  Diagram:

Step 1: clone the required git directory to the Raspberry Pi

git clone https://github.com/adafruit/Adafruit_Python_CharLCD.git

step 2: change into the directory we just cloned and run the setup file

cd ./Adafruit_Python_CharLCD

sudo python setup.py install

step 3: update  the pin variable in the file char_lcd.py

if you follow my  circuit then the value  is

lcd_rs        = 25

lcd_en        = 24

lcd_d4        = 23

lcd_d5        = 17

lcd_d6        = 18

lcd_d7        = 22

lcd_backlight = 4

lcd_columns = 16

lcd_rows = 2

 

Step 3: go to directory

cd ~/Adafruit_Python_CharLCD/examples/

Step 4:open the char_lcd.py and update the value which we listed above

Sudonano char_lcd.py

Step 5:run the  program

Sudo python char_lcd.py