Arduino audio tests using the Mozzi library, a Nano board, a light dependent resistor and a potentiometer (volume control).
http://sensorium.github.io/Mozzi/learn/introductory-tutorial/
The blog
Arduino audio tests using the Mozzi library, a Nano board, a light dependent resistor and a potentiometer (volume control).
http://sensorium.github.io/Mozzi/learn/introductory-tutorial/
Some photographs of the latest 3D prints for We Are Here.
Working through this tutorial currently, trying to understand how Processing can be used to network an Arduino and power the colour of a lamp from words featured in an XML feed (in this case my blog feed – replacing the word ‘love’ with ‘space’ and the word ‘peace’ with ‘rock’). This generates the colour #3C4C2C.

And after adding this post to the feed…
Note the slight colour change.
This is the circuit I used, from this website. The LED is a 4 pin one, which can generate any combination of RGB colour as light:

And the two versions of it that I built:


Here is the code used in Processing:
//Arduino Code for the Arduino Networked Lamp - Processing
#define SENSOR 0
#define R_LED 9
#define G_LED 10
#define B_LED 11
#define BUTTON 12
int val =0; //variable to store the value coming from the sensor
int btn = LOW;
int old_btn = LOW;
int state = 0;
char buffer[7];
int pointer = 0;
byte inByte = 0;
byte r = 0;
byte g = 0;
byte b = 0;
void setup() {
Serial.begin(9600); //open up serial port
pinMode(BUTTON, INPUT);
}
void loop() {
val = analogRead(SENSOR);
Serial.println(val);
if (Serial.available() >0) {
//read incoming byte
inByte = Serial.read();
if (inByte == '#') {
while (pointer < 6) {
buffer[pointer] = Serial.read();
pointer++;
}
//now need to decode 3 numbers of colors stored as hex numbers into 3 bytes
r = hex2dec(buffer[1]) +hex2dec(buffer[0])*16;
g = hex2dec(buffer[3]) +hex2dec(buffer[2])*16;
b = hex2dec(buffer[5]) +hex2dec(buffer[4])*16;
pointer = 0; //reset pointer
}
}
btn = digitalRead(BUTTON);
//check if there was a transition
if ((btn == HIGH) && (old_btn == LOW)) {
state = 1-state;
}
old_btn = btn; //val is now old,lets store it
if (state == 1) {
analogWrite(R_LED, r);
analogWrite(G_LED, g);
analogWrite(B_LED, b);
}
else {
analogWrite(R_LED, 0);
analogWrite(G_LED, 0);
analogWrite(B_LED, 0);
}
delay(100);
}
int hex2dec(byte c) {
if (c >= '0' && c<= '9') {
return c- '0';
} else if (c >='A' && c <= 'F') {
return c - 'A' + 10;
}
}
And the code in Arduino:
//Arduino Code for the Arduino Networked Lamp - Arduino
#define SENSOR 0
#define R_LED 9
#define G_LED 10
#define B_LED 11
#define BUTTON 12
int val =0; //variable to store the value coming from the sensor
int btn = LOW;
int old_btn = LOW;
int state = 0;
char buffer[7];
int pointer = 0;
byte inByte = 0;
byte r = 0;
byte g = 0;
byte b = 0;
void setup() {
Serial.begin(9600); //open up serial port
pinMode(BUTTON, INPUT);
}
void loop() {
val = analogRead(SENSOR);
Serial.println(val);
if (Serial.available() >0) {
//read incoming byte
inByte = Serial.read();
if (inByte == '#') {
while (pointer < 6) {
buffer[pointer] = Serial.read();
pointer++;
}
//now need to decode 3 numbers of colors stored as hex numbers into 3 bytes
r = hex2dec(buffer[1]) +hex2dec(buffer[0])*16;
g = hex2dec(buffer[3]) +hex2dec(buffer[2])*16;
b = hex2dec(buffer[5]) +hex2dec(buffer[4])*16;
pointer = 0; //reset pointer
}
}
btn = digitalRead(BUTTON);
//check if there was a transition
if ((btn == HIGH) && (old_btn == LOW)) {
state = 1-state;
}
old_btn = btn; //val is now old,lets store it
if (state == 1) {
analogWrite(R_LED, r);
analogWrite(G_LED, g);
analogWrite(B_LED, b);
}
else {
analogWrite(R_LED, 0);
analogWrite(G_LED, 0);
analogWrite(B_LED, 0);
}
delay(100);
}
int hex2dec(byte c) {
if (c >= '0' && c<= '9') {
return c- '0';
} else if (c >='A' && c <= 'F') {
return c - 'A' + 10;
}
}
This didn’t work the first time I ran it, so I had to specify the Arduino port that Processing should use and then…
Today I’ve been looking at how to build the various Arduino circuits for the Space Rocks, and at some examples of relevant projects.
I made some basic sensor experiments with a Light-dependent resistor, ultimately using this code from the Make: Getting Started with Arduino book.
// Example 06b: Blink LED at a rate specified by the
// value of the analogue input
# define LED 9 // the pin for the LED
int val = 0; // variable used to store the value
// coming from the sensor
void setup() {
// put your setup code here, to run once:
pinMode(LED, OUTPUT); // LED is as an output
// note Analogue pins are
// automatically set as inputs
}
void loop() {
// put your main code here, to run repeatedly:
val = analogRead(0); // read the value from the sensor
analogWrite(LED, val/4); // turn the LED on at
// the brightness set
// by the sensor
delay(10); // stop the program for some time
}
And this circuit:


Also stumbled upon How to Build an Arduino synthesizer with Mozzi library
The Mozzi library looks super-useful for sound generation:
Currently your Arduino can only beep like a microwave oven. Mozzi brings your Arduino to life by allowing it to produce much more complex and interesting growls, sweeps and chorusing atmospherics. These sounds can be quickly and easily constructed from familiar synthesis units like oscillators, delays, filters and envelopes.
You can use Mozzi to generate algorithmic music for an installation or performance, or make interactive sonifications of sensors, on a small, modular and super cheap Arduino, without the need for additional shields, message passing or external synths.
Note to self to also check out the Mozzi examples gallery.
The latest 3D printed prototypes for the Space Rock shapes.
Plus a video of the shells glowing, courtesy of Arduino.
Today was partly spent constructing four identical containers for the speakers and nano boards to start playing with the interactions and connectivity of the various space objects / Rocks.
Some sketches for possible installation of Space Rock objects.
A playlist of audio experiments for the installation piece ‘What Goes Around’, using the narratives and spoken word generated from my recent workshop.
Second text created using Markov chain text generation. Again, the text is in the order it was generated, although some slight edits have been made to give the text a bit more flow and ‘sense’.
was being much like those back home.
but maybe we’re not quiet.
shows not only family.
tenderly.
quite done with wandering after all.
Being from and surprises the edges.
in honour of the sounds of the object.
sparsely, tendency, finally around the screen.
much less of the object.
Under closely, which finally that.
the artist’s ranch.
When they all listen.
the council would change us all.
the moon landings.
Taken.
and the small life deciphering the stars.
come riding horses.
Some before.
the contact with wandering travel.
They travel.
object is so near as macro.
would do the pictures from the lens.
have begun.
heard the same from.
As he once again see scans them.
occasionally the Earth.
she notices that finally.
mission for survival.
Before static, waiting the home rest.
time has passed.
much; it was, but they weren’t enough the map.
some time to listen is.
a sort of us.
because life.
They played from memory and the edges.
and the bother means came naturally, tenderly.
and sounding like spider legs.
the rider closely.
communicating against the stars.
scanning their artists travel.
he came named.
You must be logged in to post a comment.