{"id":5349,"date":"2021-05-06T01:33:35","date_gmt":"2021-05-06T05:33:35","guid":{"rendered":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/?p=5349"},"modified":"2021-05-06T01:33:35","modified_gmt":"2021-05-06T05:33:35","slug":"assignment-24-rebecca-and-celia","status":"publish","type":"post","link":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/5349\/assignment-24-rebecca-and-celia\/","title":{"rendered":"Assignment 24: Rebecca and Celia"},"content":{"rendered":"\n<p>We met with Garth earlier today and were able to transfer data back and forth to eachother through MQTT! We updated the code, to take account of the data being processed into the command, as well as adjusting the collaboration of the sensor pad. Our next goal is to incorporate another sensor pad so we can control speed along with the direction of the puppets. We have also made plans to come together and assemble the environment that the puppets will be in. We would like to invite other students visit our puppet show this weekend if they would like to participate!<\/p>\n\n\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nimport time\nimport supervisor\nimport sys\n\n# Import the low-level hardware libraries.\nimport board\nimport digitalio\nimport analogio\nimport pwmio\n\nfrom adafruit_circuitplayground import cp\nfrom adafruit_motor import servo\n\n\n# ----------------------------------------------------------------\n# Initialize hardware.\n\n# Create a PWMOut object on pad SDA A5 to generate control signals.\npwm = pwmio.PWMOut(board.A5, duty_cycle=0, frequency=50)\n\n# Create a Servo object which controls a hobby servo using the PWMOut.\nactuator = servo.Servo(pwm, min_pulse=1000, max_pulse=2000)\n\n\n# Create a PWMOut object on pad SCL A4 to generate control signals.\npwm2 = pwmio.PWMOut(board.A4, duty_cycle=0, frequency=50)\n\n# Create a Servo object which controls a hobby servo using the PWMOut.\nactuator2 = servo.Servo(pwm2, min_pulse=1000, max_pulse=2000)\n\n# Configure the digital input pin used for its pullup resistor bias voltage.\nbias = digitalio.DigitalInOut(board.D10)\nbias.switch_to_input(pull=digitalio.Pull.UP)\n\n# Configure the analog input pin used to measure the sensor voltage.\nsensor = analogio.AnalogIn(board.A2)\nscaling = sensor.reference_voltage \/ (2**16)\n\n\nlast_touch = 0\ntouched_arm_one = 0\ntouched_arm_two = 0\ntouched_leg_one = 0\ntouched_leg_two = 0\n\ndef flush_check():\n    if supervisor.runtime.serial_bytes_available:\n        line = sys.stdin.readline()\n\n\n# ----------------------------------------------------------------\n# Begin the main processing loop.\nwhile True:\n    # Read the integer sensor value and scale it to a value in Volts.\n    volts = sensor.value * scaling\n    touched_arm_one = 0\n    pressure_one = (3.2 - volts) \/ (3.2 - 0.4)\n    print(pressure_one) #function to send data \n    pressure_two = (1.4 - volts) \/ (1.4 - 0.1)\n\n    if supervisor.runtime.serial_bytes_available:\n            line = sys.stdin.readline()\n            tokens = line.split()\n            if len(tokens) == 1 and float(tokens[0]) &amp;gt; .90:\n                touched_arm_one = 1\n\n    if touched_arm_one:\n        for angle in range(0, 180, 5):\n            actuator.angle = angle\n            time.sleep(0.02)\n            flush_check()\n        for angle in range(180, 0, -5):\n            actuator.angle = angle\n            time.sleep(0.02)\n            flush_check()\n    time.sleep(.5)\n\n\n\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>We met with Garth earlier today and were able to transfer data back and forth to eachother through MQTT! We updated the code, to take account of the&#8230;<\/p>\n","protected":false},"author":78,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts\/5349"}],"collection":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/comments?post=5349"}],"version-history":[{"count":2,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts\/5349\/revisions"}],"predecessor-version":[{"id":5364,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/posts\/5349\/revisions\/5364"}],"wp:attachment":[{"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/media?parent=5349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/categories?post=5349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/courses.ideate.cmu.edu\/16-376\/s2021\/wp-json\/wp\/v2\/tags?post=5349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}