Skip to content
Snippets Groups Projects
Commit 98de2709 authored by Loes's avatar Loes
Browse files

updates wk 5 and 10

parent 5dd1881a
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -606,8 +606,99 @@ For example: I might try to connect a buzzer but am not sure how to connect it.
**Ugh, despair. Why didn't I record the results right away?**
I didn't document the working piece straight away when it was working. And when I tried to do it this evening. It was buggy again. More debugging for me :(
I found that it was the connection to the power supply (the coin cell battery) was the issue. When I power the choker with the lab power supply it works perfectly (see video).
<iframe width="560" height="315" src="https://www.youtube.com/embed/4F35IlK6YNA?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
So I took off my improvised battery pouch, and replaced it with a hard battery clip to fix the problem.
<iframe width="560" height="315" src="https://www.youtube.com/embed/N0gbRPfFFjw" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
*And it's workinggggg, Loes Bogers, 2019*
****
##Analog sensor: black diamond capacitive sensing rock
I grew some alum crystals in week 9 - Textile as Scaffold. I missed this electronics week so I'm working on week 5 from the future. I made these beautiful crystals with the addition of some bare conductive ink. The documentation is [here](https://class.textile-academy.org/2020/loes.bogers/assignments/week09/)
And I made this baby work! I wrote some code for Attiny85 using softserial to see how it's reading and it's beautiful. I had the sending and receiving pin the wrong way around at first but that was easily fixed.
<iframe width="560" height="315" src="https://www.youtube.com/embed/-kNWvzDM0sc?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
```
//Code taken from these tutorials and modified by Loes Bogers
//https://www.instructables.com/id/Capacitive-Sensing-for-Dummies/
//https://www.arduino.cc/en/Tutorial/Smoothing
#include <CapacitiveSensor.h>
#include <SoftwareSerial.h> when using ATtiny and FTDI cable
#define rxPin 1 // if using FTDI cable and attiny > connect to TX of other device
#define txPin 0 // if using FTDI cable and attiny > connect to RX of other device
SoftwareSerial serial(rxPin, txPin); //if using FTDI cable and attiny
//send at pin 4, receive at pin 3, 1-10M ohm resistor between
CapacitiveSensor cs_3_4 = CapacitiveSensor(3, 4); // 1-10 megohm resistor between pins 4 & 3, pin 3 is sensor pin, add wire, foil
const int numReadings = 10; // size of array/number of readings to keep track of (higher = slower)
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
void setup() {
// initialize serial communication with computer:
// Serial.begin(9600); //start serial communication via USB cable
serial.begin(115200); //if using FTDI cable and attiny
cs_3_4.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600);
//initatialize readings array setting all values to 0
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop() {
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = cs_3_4.capacitiveSensor(30);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we're at the end of the array...wrap around to the beginning
if (readIndex >= numReadings) {
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
// Serial.println(average); // if using Arduino serial
serial.println(average); // if using FTDI cable and attiny
delay(10); // arbitrary delay to limit data to serial port
}
```
*Basic code for capacitive sensing with a black diamond, Loes Bogers, 2019*
I translated this circuit into a swatch
INSERT SWATCH
##Building an analog needle felt squeeze sensor
I had this conductive wool so started off making a sensor with that. I saw it [here](https://www.kobakant.at/DIY/?p=7795) first :)
......
# 10. E-Textiles and Wearables II
## Assignment
![](../images/wk10_heatpad1.jpg)*Lookit! My heating pad powered with a 9V battery, transistor controlled by an ATtiny (details below), Loes Bogers, 2019*
* Make a swatch with an input and output controlled with an Attiny
* Make two swatches with actuators, controlled with either Arduino or Attiny
* Figure out the Soft Serial communication to read an anolog sensor with an FTDI cable.
<iframe width="560" height="315" src="https://www.youtube.com/embed/IrJuISsyTz4?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
*Soft speaker controlled by ATtiny85, Loes Bogers, 2019*
## Results
* I made four coils that an be used as speaker coils or as heating pad, and controlled them with an Attiny85, both in a speaker circuit and as a heating pad
* I made some swatches that I dyed with thermochromic pigments
* I worked out the Soft Serial communication to read an analog sensor with an FTDI cable (I'd done this before)
* I finished a project I started in week 5 and made it work: a choker with a digital switch made of a bikini clip, an LED and a buzzer, controlled by an ATtiny. The documentation to that is under [week 5](https://class.textile-academy.org/2020/loes.bogers/assignments/week05/).
<iframe width="560" height="315" src="https://www.youtube.com/embed/4F35IlK6YNA?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
*A choker with an alarm that sounds when you take it off (see week 5 for process), Loes Bogers, 2019*
##Soft Speakers
......@@ -119,7 +129,7 @@ void loop() {
*And here's the proof ;) playing when button pressed, silent otherwise, Loes Bogers, 2019*
**Controlling a soft speaker with a DFPlayer Mini**
**Controlling a soft speaker with a DFPlayer Mini - WIP!!**
This board with a mini SD card holder that can work standalone or with an Arduino (not with the ATtiny though). You could make a full soft MP3 player with this chip! This is the [DFplayer Wiki](https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299) and here's [Liza's code](https://github.com/lizastark/Projects/tree/master/Sonic_Quilt/dfMini_tutorial) to start with. I documented how I work with ATiny extensively for week 5, which you can read [here](https://class.textile-academy.org/2020/loes.bogers/assignments/week05/)
......@@ -143,7 +153,6 @@ Important note for audio files. Careful read notes below will save you a lot of
Source: https://www.dfrobot.com/blog-277.html
## Thermochromic pigment + heating pad
**Experimenting with thermochromic pigment**
......@@ -254,10 +263,103 @@ void loop() {
*Code for heatpad OR speaker circuit with ATtiny85*
![](../images/wk10_heatpad1.jpg)*Lookit! My heating pad powered with a 9V battery, transistor controlled by an ATtiny, Loes Bogers, 2019*
<iframe width="560" height="315" src="https://www.youtube.com/embed/SYdpLaHttuY" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
##FTDI cable and soft serial for Attiny
Attiny cannot just write to the serial the way an Arduino UNO can, it doesn't have UART. But you can designate any 2 pins as RX (receive) and TX (transmit), and connect an FTDI cable to it. I have a [TTL-232R-5V cable from Farnell](https://www.googleadservices.com/pagead/aclk?sa=L&ai=DChcSEwiCmuXgqpnmAhVP4ncKHTL1B7YYABAAGgJlZg&ohost=www.google.com&cid=CAESQOD2tiG4wFpIijcjbezQf1TpzpW1UCDQloiGTyGls9IPkhgoEnmkyQ_3yWNKi0BYGwm9PdE3MAOL8ymX8S-DY-g&sig=AOD64_3_4kluOTjbSLdEXpBf9BiWpR2YdA&q=&ved=2ahUKEwjTlN7gqpnmAhXDL1AKHciGBtoQ0Qx6BAgZEAE&adurl=&bg=!IiGlITlYQkx731BU_RYCAAAATlIAAAAHCgBLX5I5nWbc1Yk7OzAUaVk9k_alV6ix5mAy9MtC7Ehnd6I79c8HYezbERdSkLG-8JsFcShX-34-URsr1GAowkWwlcDgpFFRVv0HcqyjmQDeYa6y6FITxcZqpVNaRGU-uuHgk8nAmap84jBasw1ghuJaMcdNH4TS4KtIrhP7i1kuTfGqf54QrvnAye8zZFdaIR0cEesxMixzabPfsNB9jsZD5D7i8r1cCjEXvv1IOtp4VXpLgD2fIlQfUHtP2_7vAfejJvv_MfgpwEGdIJyAhEeT6Cm9CP2sl6XOouIfUOjDkYyuBk9nKiIr5hjRuAVqpA0ABmEKS3Y56tB-uJ3a1ih4D_0UcJ-hiyynolf5JcPi1Q1U83_9I7XcMcHXX_kyLIfD6oh6Ef57Ha4aZmGw) (also comes in a 3.3V version which is nice for wearables). You have to install a bunch of drivers to use them, which can be a bit of a pain but I already have them installed. You can find the [drivers here] (https://www.ftdichip.com/Products/Cables/USBTTLSerial.htm). If you're not sure you can check whether the drivers are installed by plugging in the FTDI cable and checking under \> Ports in Arduino IDE to see if another serial port shows up. Which it did!
![](../images/wk10_driveinstall_check.jpg)*Seeing if the cable shows up, if it does you already have the necessary drivers, Loes Bogers, 2019*
Then you can use the Software Serial library in the Arduino sketch by adding ``` #include <SoftwareSerial.h> ``` at the top of the sketch. You can write to the serial using similar commands, just not capitalized like you normally would.
```serial.begin(baudrate);```
```serial.println(values);```
**Connecting the FTDI cable to a circuit**
I just used the FTDI cable for calibrating in the prototype stage, so it sufficed to connect it with some jumpers and a bread board. Note: TX is always connected to the RX of another device, and RX to TX.
* VCC to VCC
* GND to GND
* TX to the pin designated as RX in the ATtiny code!
* RX to the pin designated as TX in the ATtiny code!
![](../images/wk10_ftdicable_schematic.jpg)*How I wired up the FTDI cable to a circuit with a capacative touch sensor and an attiny, Loes Bogers, 2019*
I set up the serial connection for an analog input swatch I still had to make for week 5.
```
//https://www.instructables.com/id/Capacitive-Sensing-for-Dummies/
//https://www.arduino.cc/en/Tutorial/Smoothing
#include <CapacitiveSensor.h>
#include <SoftwareSerial.h> when using ATtiny and FTDI cable
#define rxPin 1 // if using FTDI cable and attiny > connect to TX of other device
#define txPin 0 // if using FTDI cable and attiny > connect to RX of other device
SoftwareSerial serial(rxPin, txPin); //if using FTDI cable and attiny
//send at pin 4, receive at pin 3, 1-10M ohm resistor between
CapacitiveSensor cs_3_4 = CapacitiveSensor(3, 4); // 1-10 megohm resistor between pins 4 & 3, pin 3 is sensor pin, add wire, foil
const int numReadings = 10; // size of array/number of readings to keep track of (higher = slower)
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
void setup() {
// initialize serial communication with computer:
// Serial.begin(9600); //start serial communication via USB cable
serial.begin(115200); //if using FTDI cable and attiny
cs_3_4.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example Serial.begin(9600);
//initatialize readings array setting all values to 0
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop() {
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = cs_3_4.capacitiveSensor(30);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we're at the end of the array...wrap around to the beginning
if (readIndex >= numReadings) {
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
// Serial.println(average); // if using Arduino serial
serial.println(average); // if using FTDI cable and attiny
delay(10); // arbitrary delay to limit data to serial port
}
```
*Code using Software Serial, an ATtiny and capacitive sensing*
<iframe width="560" height="315" src="https://www.youtube.com/embed/-kNWvzDM0sc?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
*The readings coming in, plotted to the serial plotter, Loes Bogers, 2019*
##Emma's tutorial on motion & sound actuators
Both motion and sound are based on the physics principles of electromagnetism. Both motors and speakers work with coils and magnets. Electricity and magnetism are good friends. If you have electricity you always also have a magnetic field. With a coil you can concentrate this magnetic field's force to a limited space, you amplify it. If you run voltage across a coil, it *becomes a magnet*, so you can move stuff around. This is the basic movement used to make a speaker work, and to make a motor turn. They also have coils.
......
docs/images/wk10_driveinstall_check.jpg

95 KiB

docs/images/wk10_ftdicable_schematic.jpg

180 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment