Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

AWS ロボを作ろう JAWSUG Kobe

3,866 views

Published on

AWSロボを作る親子イベント

Published in: Technology

AWS ロボを作ろう JAWSUG Kobe

  1. 1. !  JAWSUG –  –  – IoT –  – 
  2. 2. CloudSearch Route53 S3 DynamoDB
  3. 3. !  B !  !  SD !  LAN BUFFALO WLIBUCBGNM !  × SG90 !  × !  ! 
  4. 4. ON
  5. 5. !  PC Wifi awsrobo01 / awsrobo01 !  ssh pi@rasXX.local •  XX 00 19 •  pi raspberry !  AWS SDK curl https://bootstrap.pypa.io/getBpip.py | sudo python sudo pip install boto BBupgrade !  wget http://bit.ly/1TAYwrN BO robo.py !  sudo python robo.py
  6. 6. robo.py # -*- coding: utf-8 -*- import RPi.GPIO as GPIO import time import os import sys import boto from boto.sqs.message import RawMessage ###### GPIO Initialization ##### GPIO.cleanup() ###### Action 00 ##### def action_00(): GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.OUT) GPIO.setup(24, GPIO.OUT) p1 = GPIO.PWM(23, 50) p2 = GPIO.PWM(24, 50) p1.start(7.5) p2.start(7.5) try: p1.ChangeDutyCycle(7.5) p2.ChangeDutyCycle(7.5) time.sleep(0.3) GPIO.cleanup() except KeyboardInterrupt: GPIO.cleanup() ###### Action 01 ##### def action_01(): GPIO.setmode(GPIO.BCM) GPIO.setup(23, GPIO.OUT) GPIO.setup(24, GPIO.OUT) p1 = GPIO.PWM(23, 50) p2 = GPIO.PWM(24, 50) p1.start(7.5) p2.start(7.5) try: for var in range(0, 4): p1.ChangeDutyCycle(9.5) p2.ChangeDutyCycle(9.5) time.sleep(0.4) p1.ChangeDutyCycle(5.5) p2.ChangeDutyCycle(5.5) time.sleep(0.4) p1.ChangeDutyCycle(7.5) p2.ChangeDutyCycle(7.5) time.sleep(0.3) GPIO.cleanup() except KeyboardInterrupt: GPIO.cleanup() ##### Main ##### action_00() action_01()
  7. 7. SQS ##### Main ##### #action_00() #action_01() conn = boto.connect_sqs('ACCESS_KEY','SECRET_KEY') queue = conn.get_queue('QUEUE_NAME') queue.set_message_class(RawMessage) while 1: messages = queue.get_messages(1) for message in messages: msg = message.get_body() print(msg) queue.delete_message(message) action_00() action_01() •  •  •  •  ##### Main ##### action_00() action_01() """ conn = boto.connect_sqs('ACCESS_KEY','SECRET_KEY') queue = conn.get_queue('QUEUE_NAME') queue.set_message_class(RawMessage) while 1: messages = queue.get_messages(1) for message in messages: msg = message.get_body() print(msg) queue.delete_message(message) action_00() action_01() """
  8. 8. !  suto halt 5 USB !  sudo reboot

×