Day 11: (Wed Feb 22, Week 6) Workshop: Silicone Bonding¶
Notes for 2023-02-22.
New Assignments¶
New pair assignment, due Monday Feb 27: jointly design a proof-of-concept test part in support of your project idea. The results will vary by group.
Agenda¶
The first portion of class will be a practical hands-on workshop in demolding and silicone bonding. We will temporarily move to HL A5.
Additional demos: pneumatic air system, capacitive touch sensing, shape memory alloy.
Brief presentations of project plans for each pair to the whole class.
Shape Memory Alloy¶
Today’s test uses a Nitinol Sample Pack which includes seven samples:
0.5mm 70C (158F)
1 mm 15C (59F)
1 mm 40C (104F)
1 mm 80C (176F)
2 mm 40C (104F)
2 mm 60C (140F)
2 mm 80C (176F)
Capacitive Touch Sensing Demo¶
The easiest way to get started with capacitive touch sensing is to use a microcontroller which includes a touch interface.
Demo today: Adafruit QT Py
Microcontroller: ATSAMD21E18. See Chapter 36 for touch details.
Related application note: Capacitive Touch Sensor Design Guide
Sample code in CircuitPython:
1# Adafruit QT Py touch demo
2
3# To run, this file should be copied to the CIRCUITPY drive as code.py
4
5# related docs:
6
7# https://docs.circuitpython.org/en/latest/shared-bindings/touchio/index.html
8# https://learn.adafruit.com/adafruit-qt-py/pinouts#capacitive-touch-pins-3073279
9# https://learn.adafruit.com/adafruit-qt-py/circuitpython-internal-rgb-led
10# https://www.adafruit.com/product/4600
11
12import time
13import board
14import digitalio
15import touchio
16import neopixel_write
17
18#------------------------------------------------------------------
19# A0, A1, A2, A3, A6 (TX), A7 (RX) can be capacitive touch pins without the need for a separate driver pin.
20touch_inputs = [touchio.TouchIn(pin) for pin in [board.A0, board.A1, board.A2, board.A3, board.A6, board.A7]]
21
22# Each touch sensor emits a different color.
23colors = ((255, 0, 0), # red
24 (255, 255, 0), # yellow
25 ( 0, 255, 0), # green
26 ( 0, 255, 255), # cyan
27 ( 0, 0, 255), # blue
28 (255, 0, 255), # magenta
29 )
30
31black = (0,0,0)
32
33#------------------------------------------------------------------
34# The NeoPixel uses one GPIO output for sending color data.
35pixels = digitalio.DigitalInOut(board.NEOPIXEL)
36pixels.direction = digitalio.Direction.OUTPUT
37
38# The NeoPixel API needs a data object implementing the buffer protocol.
39frame_buffer = bytearray(3)
40
41# Helper function to accept a color tuple. The NeoPixel has GRB color ordering.
42def set_color(color):
43 frame_buffer[0] = color[1]
44 frame_buffer[1] = color[0]
45 frame_buffer[2] = color[2]
46 neopixel_write.neopixel_write(pixels, frame_buffer)
47
48# Turn on the NeoPixel.
49power = digitalio.DigitalInOut(board.NEOPIXEL_POWER)
50power.direction = digitalio.Direction.OUTPUT
51power.value = True
52
53#------------------------------------------------------------------
54# Constantly read the touch sensors and emit color.
55
56last_touch = None
57
58while True:
59
60 # read all the touch sensors; this will produce a list of Boolean values
61 active = [sensor.value for sensor in touch_inputs]
62
63 # if any are active, set the Neopixel color based on the first
64 if any(active):
65 idx = active.index(True)
66 set_color(colors[idx])
67
68 if last_touch != idx:
69 print("Touch on", idx)
70 last_touch = idx
71
72 else:
73 set_color(black)
74 last_touch = None