Tuesday, March 19, 2019

Tuesday March 19, 2019 - Shell Scripts in Python

Entry Ticket - Dive into chatbots- a beginner hands on workshop

Challenge - Extra Credit -  using linux command line or Python code can you copy a file from your Raspberry Pi to your google drive?  Can you copy one from your google drive to your Raspbeery Pi?

 Instructables - Photo Booth
See - https://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins/

See Lesson 4 for Setting up the Video
https://www.instructables.com/lesson/Navigate-the-Raspberry-Pis-Software-Part-2/
run
 sudo apt-get update
 sudo apt-get install imagemagick
 
run the nano text editor
 nano helloMe.sh 
in the editor type
  #!/bin/sh
  raspistill -w 800 -h 600 -t 10000 -tl 2000 -o image%02d.jpg
  convert -delay 10 -loop 0 image*.jpg animateMe.gif 


See lesson 5 for Setting up the Audio
https://www.instructables.com/lesson/Intro-to-Sonic-Pi-and-Playing-Media/

in the command shell run
  amixer cset numid=3 1
 
then run 
 sudo apt-get install mpg321 -y

to paly a mp3 file run
  mpg321 fileName.mp3
 
See lesson 6 for Scripting
 https://www.instructables.com/lesson/Intro-to-Python/


The GPIO.BOARD option specifies that you are referring to the pins by the number of the pin the the plug - i.e the numbers printed on the board (e.g. P1) and in the middle of the diagrams below.
The GPIO.BCM option means that you are referring to the pins by the "Broadcom SOC channel" number, these are the numbers after "GPIO" in the green rectangles around the outside of the below diagrams:
Unfortunately the BCM numbers changed between versions of the Pi1 Model B, and you'll need to work out which one you have guide here. So it may be safer to use the BOARD numbers if you are going to use more than one Raspberry Pi in a project.
#GPIO
# 3.3v = 1,17, 5.0v =2,4 GND = 6,9,14,20,25,30,34,39
# my LED is on Pin 3 and Ground is on Pin 6
import RPi.GPIO as GPIO
from time import sleep # import time library 
GPIO.setmode(GPIO.BOARD)
myOutLED = 3
myInputSwitch = 5
GPIO.setup(myOutLED, GPIO.OUT)
GPIO.setup(myInputSwitch, GPIO.IN)
while True :
    inputState = GPIO.input(myInputSwitch)
    print(inputState)
    if inputState == False:
        print('button pressed')
        photoCounter=4
        while (photoCounter > 0):
            GPIO.output(myOutLED, True)
            print('  LED ON')
            sleep(1)
            GPIO.output(myOutLED, False)
            print('  LED OFF')
            sleep(1)
            photoCounter=photoCounter-1

GPIO.cleanup()
Open LAB  and/or Robot Club 
  • LAB - Duration: 60 Min
  • Link: Robot Club Google Sites
  • Instructions & Expectations: Connect with your Robot Club Team.  You will either be working on your Robot Project or an Open Lab Project.  
    • You will need to account for your time. You will need to convince me by your form submission that you worked given the time allotted. 
    • If  you or your Robot Club Team worked on the Robot Club project, you will make sure your Robot Project Status Google docs are updated.  
    • If you worked on an Open Lab Project, you will also need to tell me about what you accomplished and what you are planning next.
  • How to Submit Assignment:   Each Student needs to account for your time.  
  • Dig Deeper: Open Lab:
Clean Up
  • Assignment - Duration: 2-10 Min
  • Instructions & Expectations: Desk cleanup, put away all projects, find your assigned job
  • How to Submit Assignment: When Complete, check yourself off on Sign Out Sheet - 2 Points

No comments:

Post a Comment