Day 13: (Wed Mar 1, Week 7) Actuators and Sensors

Notes for 2023-03-01.

Assignments

  1. Please be sure to post a result for the ‘proof-of-concept’ design milestone which was due this past Monday.

  2. If you will need any particular materials or components, please let me know before the end of the week so I can place orders.

  3. No formal assignment over the break.

Administrative

We next meet Monday March 13 after Spring Break.

Agenda

  • DC Motor Air Pump

  • Peristaltic Liquid Pump

  • Capacitive Touch Sensing

  • Ferrofluid

DC Motor Air Pump

Peristaltic Liquid Pump

Capacitive Touch Sensing Demo

The CAP1188 can read eight channels of capacitive sensing. The interface includes recalibration controls and raw data which may make it more suitable for proximity detection.

Demo today: Adafruit CAP1118 Touch Sensor

Touch controller: https://www.microchip.com/en-us/product/CAP1188

Raspberry Pi Pico:

Sample code in CircuitPython:

 1# Adafruit CAP1188 Capacitive Touch Sensor demo for Raspberry Pi Pico
 2
 3# To run, this file should be copied to the CIRCUITPY drive as code.py
 4
 5# Note: this sketch requires the optional adafruit_cap1188 library
 6# which should be copied as a folder to CIRCUITPY/lib on the Pico.
 7# The adafruit_cap1188 folder can be found within the library bundle
 8# available from https://circuitpython.org/libraries
 9
10# related docs:
11#  https://www.adafruit.com/product/1602
12#  https://learn.adafruit.com/adafruit-cap1188-breakout
13#  https://learn.adafruit.com/adafruit-cap1188-breakout/python-circuitpython
14#  https://docs.circuitpython.org/projects/cap1188/en/latest/
15
16# wiring for I2C on a Raspberry Pi Pico:
17#  pin 36, 3V3(OUT)      ->      sensor VIN
18#  pin 38, GND           ->      sensor GND
19#  pin 1, I2C0 SDA, GP0  ->      sensor SDA
20#  pin 2, I2C0 SCL, GP1  ->      sensor SCK
21
22#------------------------------------------------------------------
23import time
24import board
25import busio
26
27from adafruit_cap1188.i2c import CAP1188_I2C
28
29#------------------------------------------------------------------
30# initialize the hardware interface objects
31
32# this assumes the wiring noted above
33i2c = busio.I2C(scl=board.GP1, sda=board.GP0)
34cap = CAP1188_I2C(i2c)
35
36#------------------------------------------------------------------
37print("initial thresholds:", cap.thresholds)
38print("sensitivity:", cap.sensitivity)
39print("averaging:", cap.averaging)
40print("touch state:", cap.touched_pins)
41
42# Notes:
43#    cap.recalibrate()    will recalibrate all channels,
44#    cap[n].recalibrate() will recalibrate a single channel.
45#------------------------------------------------------------------
46
47# Constantly read the touch sensors and print messages.
48while True:
49    for i in range(1, 9):
50        if cap[i].value:
51            print("Pin", i, "touched, raw value is", cap[i].raw_value, "threshold is", cap[i].threshold)