GithubHelp home page GithubHelp logo

ai_installation_art_icci's Introduction

AI Installation Art

Artificial Intelligence Installation Art Official Course Page of ICCI SJTU

依赖软件

VSCode:

putty:

实验

SSH连接树莓派:

绿色(8C:42):

蓝色(5A:F5):

粉红色(8C:C2):

ip地址在课堂上即时获取

作业提交

作业提交网址(jbox):jbox

树莓派IO接口

io

实验及代码

实验一--红外传感器:

参考代码:

Photoelectric switch

from gpiozero import Button
import time

switch = Button(17)

while True:
    if switch.is_pressed:
        pass
    else:
        print("Object detected!")
    time.sleep(0.2) # 以每秒5次的频率检测,
                    # 也就是5Hz检测频率

随堂练习

from gpiozero import Button
import time

switch = Button(17)

while True:
    if switch.is_pressed:
        pass
    else:
        count = count + 1
        if count == 10:
            print("Object was detected {} times".format(count))
            count = 0
    time.sleep(0.2) # 以每秒5次的频率检测,
                    # 也就是5Hz检测频率

实验二--人体动作检测传感器:

传感器实物图:

motion sensor

参考代码:

from gpiozero import MotionSensor
import time

pir = MotionSensor(14)

while True:
    if pir.motion_detected:
        # 获得当前时间的格式化字符串
        time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        print("{}, motion detected!".format(time_str))
    else:
        pass
    time.sleep(0.2) # 以每秒5次的频率检测,
                    # 也就是5Hz检测频率

实验三:雨滴传感器

传感器实物图:

water sensor

from gpiozero import Button
import time
switch = Button(26)

while True:
    if switch.is_pressed:
        time_str = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        print("{}, water detected!".format(time_str))
    else:
        pass
    time.sleep(0.2) # 以每秒5次的频率检测,
                    # 也就是5Hz检测频率

随堂练习

from gpiozero import Button
import time
switch = Button(26)

count  = 0

total_count = int(5 / 0.2) # 将5秒换算成检测到的次数

while True:
    if switch.is_pressed:
        count = count + 1
        if count >= total_count:
            print("The object was immersed in water for more than 5 seconds!")
            count = 0 # 计数置零,从头计数
    else:
        count = 0 # 一旦期间有一次被检测到没有泡在水里直接置零
    time.sleep(0.2) # 以每秒5次的频率检测,
                    # 也就是5Hz检测频率

实验四:超声波传感器:

传感器实物图:

radar

from gpiozero import DistanceSensor
from time import sleep
sensor = DistanceSensor(echo=23, trigger=24)

while True:
    print('Distance to nearest object is', sensor.distance, 'm')
    sleep(1)

随堂练习

from gpiozero import DistanceSensor
from time import sleep
sensor = DistanceSensor(echo=23, trigger=24)

while True:
    if sensor.distance <= 0.1:
        print("Alert: The object is less than 10cm away from us")
    sleep(1)

相关信息

任何问题请邮件:xuanhong chen

对研究项目感兴趣的同学也可以邮件咨询,欢迎对于虚拟人电影换脸人脸重建AIGC感兴趣的同学前来咨询。

相关链接:

ai_installation_art_icci's People

Contributors

neuralchen avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.