Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Raspberry pi講習会 3回目

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Raspberry pi講習会 3回目

ラズパイにサーバを立ててブラウザからLチカしよう!

Avatar for teru0x1

teru0x1

May 09, 2018
Tweet

More Decks by teru0x1

Other Decks in Technology

Transcript

  1. PYTHONͷ෮श def get_average(mylist, size): “""ؔ਺ݺͼग़࣌͠ʹ mylist = score, size =

    4ͷ୅ೖ͕ߦΘΕΔ""" sum = 0 for i in mylist: sum += i # a += 1 ͸ a = a + 1Λҙຯ͢Δ return sum / size score = [70, 82, 88, 90] average = get_average(score, 4) print("average:{}".format(average))
  2. ॳΊͯͷαʔό ϗʔϜσΟϨΫτϦʹserverσΟϨΫτϦΛ࡞੒͠ɺͦͷதʹserver.pyΛ࡞੒͠Α͏ɻ # ඞཁͳϞδϡʔϧͷಡΈࠐΈ from bottle import Bottle, run, post,

    request, redirect # BottleΦϒδΣΫτʢΠϯελϯεʣͷ࡞੒ app = Bottle() @app.route('/') def handle(): return "hello, bottle" run(app, host="your_ip_addr", port=8080)
  3. ࢖͍ํ؆୯Ͱ͢ɻ import wiringpi wiringpi.wiringPiSetupGpio() # For GPIO pin numbering wiringpi.pinMode(6,

    1) # Set pin 6 to 1 ( OUTPUT ) wiringpi.digitalWrite(6, 1) # Write 1 ( HIGH ) to pin 6 wiringpi.digitalRead(6) # Read pin 6
  4. ม਺ͷείʔϓ >>> a = 10 >>> def hoge(): ... a

    += 1 ... print(a) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<stdin>", line 2, in hoge UnboundLocalError: local variable 'a' referenced before assignment