Skip to main content

4-step sequencer

not really textile related exactly, but I do intend to plug whatever fabric I happen to make on the loom this week into this code and use it to generate sound.

this is the code

i'm really just putting this up here so I have it in another place in case I lose it because I'll no doubt forget how i did this and have to figure out from scratch how i did it if i lose the file.

the main thing about this is that it doesn't matter that much really  what resistive range I can get on any particular textile sensor that I create now because I'm not using the actual value of the resistor resistance (ugh, whatever) to enter values into the program. what i'm doing is mapping the range of the whole resistor to a different variable. so whether the range of the resistor is 0-10000ohm or 0-200000ohm it doesn't matter, I can just map those values to the range of 0-1000

With any luck the cloth will work out and I can make a little sequencer control panel out of cloth.

Arduino is so much fun.

Wish my dog would relax though.

//variable pitch square wave generator
//reads value from potentiometer
//maps said value to provide Microsecond delay
//23.01.12
//Andrew Kieran

int potOne = 0; // timer pot
int potTwo = 0; // step one pot
int potThree = 0; // step two pot
int potFour = 0; // step threepot
int potFive = 0; // step four pot
int potOneOut = 0; // mapped value from pot one, timer repeat
int potTwoOut = 0; // mapped value from pot two, step two frequency
int potThreeOut = 0; //mapped value from pot three, step three freq
int potFourOut = 0;
int potFiveOut = 0;
const int potOnePin = A0;
const int potTwoPin = A1;
const int potThreePin  = A2;
const int potFourPin = A3;
const int potFivePin = A4;
const int outPin = 9;
unsigned long Timer; // hmmmmmm


void setup() {
  pinMode (potOne, INPUT);
  pinMode (potTwo, INPUT);
  pinMode (potThree, INPUT);
  pinMode (potFour, INPUT);
  pinMode (potFive, INPUT);
  pinMode (outPin, OUTPUT);
}

void loop () {
  potOne = analogRead(potOnePin);
  potOneOut = map(potOne, 0, 1000, 0, 1000);
  Timer = millis();
  stepOne();
  Timer = millis();
  stepTwo();
  Timer = millis();
  stepThree();
  Timer = millis();
  stepFour();
}

void stepOne(){
  while (millis()-Timer<=potOneOut){
    potTwo = analogRead(potTwoPin);
    potTwoOut = map(potTwo, 0, 1000, 0, 5000);
    digitalWrite(outPin, HIGH);
    delayMicroseconds(potTwoOut);
    digitalWrite(outPin, LOW);
    delayMicroseconds(potTwoOut);
  }
}

void stepTwo(){
  while (millis()-Timer<=potOneOut){
    potThree = analogRead(potThreePin);
    potThreeOut = map(potThree, 0, 1000, 0, 5000);
    digitalWrite(outPin, HIGH);
    delayMicroseconds(potThreeOut);
    digitalWrite(outPin, LOW);
    delayMicroseconds(potThreeOut);
  }
}
void stepThree(){
  while (millis()-Timer<=potOneOut){
    potFour = analogRead(potFourPin);
    potFourOut = map(potFour, 0, 1000, 0, 5000);
    digitalWrite(outPin, HIGH);
    delayMicroseconds(potFourOut);
    digitalWrite(outPin, LOW);
    delayMicroseconds(potFourOut);
  }
}
void stepFour(){
  while (millis()-Timer<=potOneOut){
    potFive = analogRead(potFivePin);
    potFiveOut = map(potFive, 0, 1000, 0, 5000);
    digitalWrite(outPin, HIGH);
    delayMicroseconds(potFiveOut);
    digitalWrite(outPin, LOW);
    delayMicroseconds(potFiveOut);
  }
}

Comments

Meg said…
Woo hoo, loopy loop! :->>>>>

Popular posts from this blog

Tablet Weaving Lesson #1: Backstrap weaving a simple diamond motif

This is the first in a series of video and photo tutorials showing basic to advanced tablet-weaving concepts. These lessons shall each build on the last and hopefully take the viewer from simple diamond patterns up to more complicated double face pattern weaving with finer yarns and eventually onto the heady heights of brocading and other fancy techniques (just as soon as I learn how to do them myself). In this first lesson we'll learn the basic weaving steps involved in weaving a diamond pattern in the backstrap style. This lesson is meant for someone who has purchased a ready-made warp from me. The next lesson shall detail how to design and make this warp oneself. And we begin This is the basic pattern we are making. The woven band is tied to my waist with another strap. I am holding a small stick shuttle in my right hand which contains the weft. In front of me are the cards, each card has 4 warp threads going through it. The gap that you can see is called the ...

treble-cloth construction

I am currently in the process of designing a triple layered fabric. One layer shall carry conductive warp threads (one out of every three), another layer shall carry conductive weft threads (again, one out of every three) and a third layer shall lay between them and act as an insulator, keeping them apart and preventing unwanted contact between the two conductive layers. Constructing a treble cloth is a compicated process. The way that a treble cloth is woven is that first the face cloth is woven, then the centre cloth is woven, then the back cloth is woven. This is a draft for a treble cloth. The crosses indicate weaving marks for the cloth currently being woven, the dashes are lifts and are used to indicate shafts that are being lifted in the case of layers that are above the layer currently being woven. Blue is back, Red is front, Green is centre (All three layers are plain weave btw) The cloth is constructed like so 1: Back cloth is woven. All red and green marks are lif...

Building a jack loom Part 1: Vague plans and messy diagrams

I've been thinking about it for a while to be fair. What I'm thinking about is an 8 shaft folding jack loom. The interesting part comes when I point out that I'm going to build an electric dobby controller into the bottom of it so it operates from one pedal and a computer program. So far I've been thinking and thinking and I'm basically roughly copying the kind of frame you'd find in a Siever's school or Baby wolf loom. Basically it's like an X that folds up on itself with the castle in the middle. Should be able to reduce it's depth from 3 feet to about 1 for storage. I don't think it's really that difficult to design the loom frame, aside from building the beams and making the ratchets and so on, which I may just jigsaw out of thick MDF. I have most of the wood I need asides from some panelling and I need to buy some aluminium sheet to make the shaft dividers with and also to hold the shaft bodies together with. The rising levers w...