Difference between revisions of "Final project idea"

From Fab Lab Wiki - by NMÍ Kvikan
Jump to: navigation, search
(Created project page)
 
(Updated project page)
Line 1: Line 1:
 +
8.2.2016 (ish)
 +
 
I decided on a sequencer and controllers for making analogue sound, for my final project. My current vision of it is a simple sequencer where I can easily manipulate the pitch, velocity and length of individual notes. You can also change the rate and number of notes in a loop. 8 to 16 notes for starters will be enough and I can extend the project later, once I have the basics right.
 
I decided on a sequencer and controllers for making analogue sound, for my final project. My current vision of it is a simple sequencer where I can easily manipulate the pitch, velocity and length of individual notes. You can also change the rate and number of notes in a loop. 8 to 16 notes for starters will be enough and I can extend the project later, once I have the basics right.
  
Line 9: Line 11:
  
 
I will be updating as I progress...
 
I will be updating as I progress...
 +
 +
 +
10.2.2016 UPDATE
 +
 +
Here are some iterations of code that I made, trying to figure out components of a simple step sequence of 4 LEDs. The first is copied from "BlinkWithoutDelay" from Arduino examples.
 +
 +
const int a = 13;
 +
 +
int ledState = LOW;
 +
 +
unsigned long prevMillis = 0;
 +
 +
const long freq = 1500;
 +
 +
 +
void setup() {
 +
 
 +
  pinMode(1, OUTPUT);
 +
  pinMode(2, OUTPUT);
 +
 
 +
}
 +
 +
void loop() {
 +
 
 +
  unsigned long currentMillis = millis();
 +
 
 +
  if (currentMillis - prevMillis >= freq) {
 +
    prevMillis = currentMillis;
 +
   
 +
    if (ledState == LOW) {
 +
      ledState = HIGH;
 +
    }
 +
    else {
 +
      ledState = LOW;
 +
    }
 +
 
 +
  digitalWrite(a, ledState);
 +
 
 +
}
 +
}
 +
 +
This is my first attempt to make 4 LEDs blink in sequence. The thought behind this code is having 1000 ms loop (looptime) and using division to light up the LEDs in sequence.
 +
 +
How this iteration is actually checking it:
 +
1000/4    = LED a
 +
(1000/4)*2 = LED b
 +
(1000/4)*3 = LED c
 +
1000      = LED d
 +
 +
The problem with the division code in this version is that I'm using = instead of ==. The former is an assigment operator, which means it sets the value instead of checking it. Also the digitalWrite function is not set right. I will be fixing these in the next versions.
 +
 +
It compiles with no problems, but does nothing to the LEDs.
 +
 +
int a = 13;
 +
int b = 12;
 +
int c = 11;
 +
int d = 10;
 +
 +
const int looptime = 1000;
 +
 +
int zero = 0;
 +
 +
void setup() {
 +
 
 +
  pinMode(a, OUTPUT);
 +
  pinMode(b, OUTPUT);
 +
  pinMode(c, OUTPUT);
 +
  pinMode(d, OUTPUT);
 +
 
 +
}
 +
 +
void loop() {
 +
 
 +
  int time = millis();
 +
 
 +
  if (time = looptime/4)
 +
  digitalWrite(
 +
  a = HIGH;
 +
  b = LOW;
 +
  c = LOW;
 +
  d = LOW;
 +
  );
 +
 
 +
  if (time = (looptime/4) * 2)
 +
  digitalWrite(
 +
  a = LOW;
 +
  b = HIGH;
 +
  c = LOW;
 +
  d = LOW;
 +
  );
 +
 
 +
  if (time = (looptime/4) * 3)
 +
  digitalWrite(
 +
  a = LOW;
 +
  b = LOW;
 +
  c = HIGH;
 +
  d = LOW;
 +
  );
 +
 
 +
  if (time = looptime)
 +
  digitalWrite(
 +
  a = LOW;
 +
  b = LOW;
 +
  c = LOW;
 +
  d = HIGH;
 +
  );
 +
 +
 +
Here's the next version. I fixed the millis function "time" to be unsigned long and not an int. The long can handle bigger numbers so that it won't overlap as quickly as int. In this example it won't make a difference I guess since the purpose of this code would be to go to 1000 ms and start again. Speaking of which there is no code in this version attempting to restart the millis count.
 +
 +
I also fixed the digitalWrite code.
 +
 +
 +
void loop() {
 +
 
 +
  unsigned long time = millis();
 +
 
 +
  if (time == looptime/4) {
 +
  digitalWrite (a, HIGH);
 +
  digitalWrite (b, LOW);
 +
  digitalWrite (c, LOW);
 +
  digitalWrite (d, LOW);
 +
  }
 +
  if (time == (looptime/4) * 2) {
 +
  digitalWrite (b, HIGH);
 +
  digitalWrite (a, LOW);
 +
  digitalWrite (c, LOW);
 +
  digitalWrite (d, LOW);
 +
  }
 +
  if (time == (looptime/4) * 3) {
 +
  digitalWrite (c, HIGH);
 +
  digitalWrite (a, LOW);
 +
  digitalWrite (b, LOW);
 +
  digitalWrite (d, LOW);
 +
  }
 +
  if (time == looptime) {
 +
  digitalWrite (d, HIGH);
 +
  digitalWrite (a, LOW);
 +
  digitalWrite (b, LOW);
 +
  digitalWrite (c, LOW);
 +
  }
 +
  }
 +
}
 +
 +
 +
 +
 +
void loop() {
 +
 
 +
  unsigned long time = millis();
 +
 
 +
  if (time <= looptime) {
 +
 
 +
  if (time <= looptime/4 && time >= 0) {
 +
    digitalWrite (a, HIGH);
 +
    digitalWrite (b, LOW);
 +
    digitalWrite (c, LOW);
 +
    digitalWrite (d, LOW);
 +
  }
 +
  if (time <= (looptime/2) && time >= (looptime/4)) {
 +
    digitalWrite (a, LOW);
 +
    digitalWrite (b, HIGH);
 +
    digitalWrite (c, LOW);
 +
    digitalWrite (d, LOW);
 +
   
 +
  }
 +
  if (time <= (looptime/4)*3 && time >= looptime/2) {
 +
  digitalWrite (a, LOW);
 +
  digitalWrite (b, LOW);
 +
  digitalWrite (c, HIGH);
 +
  digitalWrite (d, LOW);
 +
  }
 +
  if (time >= (looptime/4)*3 && time <= looptime) {
 +
  digitalWrite (a, LOW);
 +
  digitalWrite (b, LOW);
 +
  digitalWrite (c, LOW);
 +
  digitalWrite (d,HIGH);
 +
  }
 +
  else (time == looptime); {
 +
    time = zero;
 +
  }
 +
  }

Revision as of 15:48, 10 February 2016

8.2.2016 (ish)

I decided on a sequencer and controllers for making analogue sound, for my final project. My current vision of it is a simple sequencer where I can easily manipulate the pitch, velocity and length of individual notes. You can also change the rate and number of notes in a loop. 8 to 16 notes for starters will be enough and I can extend the project later, once I have the basics right.

For manipulating the actual sound signal I'm visioning controllers that fit in your hand. A cube, pyramid or sphere could be turned to trigger tilt sensors and they would have pressure sensors under circular living hinge areas that could also be used to affect parameters like pitch, FM modulation, waveform etc. Touch sensors and LEDs could be put under surfaces to make the casing feel more transparent.

I'm looking for an intuitive music creation kit. That's essentially what would be inside. On the surface I'm planning to have natural materials to make the whole system a pleasure to touch.

The first thing I will do is learn how to program and build a very simple sequence of notes. Alternatively I could find an existing project like this and reduce from that.

I will be updating as I progress...


10.2.2016 UPDATE

Here are some iterations of code that I made, trying to figure out components of a simple step sequence of 4 LEDs. The first is copied from "BlinkWithoutDelay" from Arduino examples.

const int a = 13;

int ledState = LOW;

unsigned long prevMillis = 0;

const long freq = 1500;


void setup() {
 
 pinMode(1, OUTPUT);
 pinMode(2, OUTPUT);
 
}

void loop() {
 
 unsigned long currentMillis = millis();
 
 if (currentMillis - prevMillis >= freq) {
   prevMillis = currentMillis;
   
   if (ledState == LOW) {
     ledState = HIGH;
   }
   else {
     ledState = LOW;
   } 
 
 digitalWrite(a, ledState);
 
}
}

This is my first attempt to make 4 LEDs blink in sequence. The thought behind this code is having 1000 ms loop (looptime) and using division to light up the LEDs in sequence.

How this iteration is actually checking it: 1000/4 = LED a (1000/4)*2 = LED b (1000/4)*3 = LED c 1000 = LED d

The problem with the division code in this version is that I'm using = instead of ==. The former is an assigment operator, which means it sets the value instead of checking it. Also the digitalWrite function is not set right. I will be fixing these in the next versions.

It compiles with no problems, but does nothing to the LEDs.

int a = 13;
int b = 12;
int c = 11;
int d = 10;

const int looptime = 1000;

int zero = 0;

void setup() {
 
 pinMode(a, OUTPUT);
 pinMode(b, OUTPUT);
 pinMode(c, OUTPUT);
 pinMode(d, OUTPUT);
 
}

void loop() {

 int time = millis();
 
 if (time = looptime/4) 
  digitalWrite(
  a = HIGH;
  b = LOW;
  c = LOW;
  d = LOW;
  );
 
 if (time = (looptime/4) * 2)
  digitalWrite( 
  a = LOW;
  b = HIGH;
  c = LOW;
  d = LOW;
  );
 
 if (time = (looptime/4) * 3)
  digitalWrite( 
  a = LOW;
  b = LOW;
  c = HIGH;
  d = LOW;
  );
  
 if (time = looptime) 
  digitalWrite(
  a = LOW;
  b = LOW;
  c = LOW;
  d = HIGH;
  );


Here's the next version. I fixed the millis function "time" to be unsigned long and not an int. The long can handle bigger numbers so that it won't overlap as quickly as int. In this example it won't make a difference I guess since the purpose of this code would be to go to 1000 ms and start again. Speaking of which there is no code in this version attempting to restart the millis count.

I also fixed the digitalWrite code.


void loop() {
 
 unsigned long time = millis();
 
 if (time == looptime/4) {
  digitalWrite (a, HIGH);
  digitalWrite (b, LOW);
  digitalWrite (c, LOW);
  digitalWrite (d, LOW);
 }
 if (time == (looptime/4) * 2) {
  digitalWrite (b, HIGH);
  digitalWrite (a, LOW);
  digitalWrite (c, LOW);
  digitalWrite (d, LOW);
 }
 if (time == (looptime/4) * 3) {
  digitalWrite (c, HIGH);
  digitalWrite (a, LOW);
  digitalWrite (b, LOW);
  digitalWrite (d, LOW);
 }
 if (time == looptime) {
  digitalWrite (d, HIGH);
  digitalWrite (a, LOW);
  digitalWrite (b, LOW);
  digitalWrite (c, LOW);
 }
 }
}



void loop() {

 unsigned long time = millis();
 
 if (time <= looptime) {
 
 if (time <= looptime/4 && time >= 0) {
   digitalWrite (a, HIGH);
   digitalWrite (b, LOW);
   digitalWrite (c, LOW);
   digitalWrite (d, LOW);
 }
 if (time <= (looptime/2) && time >= (looptime/4)) {
   digitalWrite (a, LOW);
   digitalWrite (b, HIGH);
   digitalWrite (c, LOW);
   digitalWrite (d, LOW);
   
 }
 if (time <= (looptime/4)*3 && time >= looptime/2) {
  digitalWrite (a, LOW);
  digitalWrite (b, LOW);
  digitalWrite (c, HIGH);
  digitalWrite (d, LOW);
 }
 if (time >= (looptime/4)*3 && time <= looptime) {
  digitalWrite (a, LOW);
  digitalWrite (b, LOW);
  digitalWrite (c, LOW);
  digitalWrite (d,HIGH);
 }
 else (time == looptime); {
   time = zero;
 }
 }