Introduction: Voice Activated Drawing Machine (rough Prototype)

About: Collaborative designer interested in combining electronics with ceramics.

This Instructable is for a prototype. It needs further development but the code to split sound into movement works.

The Visible and Tactile Sound project turns sounds into patterns.

Sound is spoken into or played via a mobile phone that acts as a microphone and amplifier. Using an Arduino with a Spectrum Shield as a graphic equaliser, different frequencies of sound make motors react instead of light. The motors control the speed and direction of a turntable (which holds the target object) and the height of a pendulum, which is fitted to deliver clay slip but could hold paint instead.

The shape the pendulum draws is altered by the rotation of the turntable.

This Instructable is for a prototype. It needs further development but the code to split sound into movement works fine.

Supplies

The majority of the materials for this project were free as they were reclaimed or repurposed. I laser cut the gears but they could be made in a different way.

  • 2 Pcs L298N Dual H Bridge DC Motor Driver
  • Sparkfun Spectrum shield
  • DC12V Reversible High Torque Turbo Worm Geared Motor
  • universal mounting hub 6mm (2 pack)
  • Ardunio Uno

Step 1: The Code. I'm Sorry This Looks Horrible. I'll Sort It Out When I Find Out How!

/******************************************************************************
SparkFun Spectrum Shield Demo Toni Klopfenstein @ SparkFun Electronics December 2015 https://github.com/sparkfun/Spectrum_Shield

This sketch shows the basic functionality of the Spectrum Shield, working with a basic RGB LED Matrix.

The Spectrum Shield code is based off of the original demo sketch by Ben Moyes @Bliptronics. This sketch is available in the Spectrum Shield repository.

Development environment specifics: Developed in Arduino 1.6.

This code is beerware; if you see me (or any other SparkFun employee) at the local, and you've found our code helpful, please buy us a round! Distributed as-is; no warranty is given.

Spectrum shield frequency allocation 0 solenoid - needs to open when voice detected - most sensitive 1 Turntable Motor Anticlockwise TMotorAnti 2 Turntable Motor Clockwise TMotorClock 3 Turntable Motor Speed TMotorSpeed DONE 4 Pendulum Motor Anticlockwise PMotorAnti 5 Pendulum Motor Clockwise PMotorClock 6 Pendulum Motor Speed PMotorSpeed *********************************************************************************

/Declare Spectrum Shield pin connections on arduino - dont use these pins again #define STROBE 4 #define RESET 5 #define DC_One A0 #define DC_Two A1

/*******************H Bridge code*****************************/ //these pins go from the H bridge to the arduino pins #define enA 11 #define in1 8 #define in2 9

#define enB 10 #define in3 7 #define in4 6

/*******************pendulum switch code*****************************/ //these pins go from arduino to the switches on the pendumum motor

#define pushButtonLeft 2 #define pushButtonRight 3 int buttonStateLeft = HIGH; int buttonStateRight = HIGH;

//Define LED connections on the Arduino/Shield //int LED[] = {7, 8, 9, 10, 11, 12, 13};

//Define spectrum variables Turntable Motor Pendulum Motor int freq_amp; int Frequencies_One[7]; int Frequencies_Two[7]; int i; int TMotorSpeed = 100; int PMotorSpeed = 100;

/********************Setup Loop*************************/ void setup() { Serial.begin(9600);

//Set spectrum Shield pin configurations pinMode(STROBE, OUTPUT); pinMode(RESET, OUTPUT); pinMode(DC_One, INPUT); pinMode(DC_Two, INPUT); digitalWrite(STROBE, HIGH); digitalWrite(RESET, HIGH);

//Initialize Spectrum Analyzers digitalWrite(STROBE, LOW); delay(1); digitalWrite(RESET, HIGH); delay(1); digitalWrite(STROBE, HIGH); delay(1); digitalWrite(STROBE, LOW); delay(1); digitalWrite(RESET, LOW);

//Pins for the H Bridge pinMode(in1, OUTPUT); pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT);

// Set initial rotation direction analogWrite (enA, TMotorSpeed); TMotorAnti();

//reading the switches on the pendulum motor // make the pushbutton's pin an input: pinMode(pushButtonLeft, INPUT_PULLUP); pinMode(pushButtonRight, INPUT_PULLUP); }

/**************************Main Function Loop*****************************/ void loop() {

Read_Frequencies(); //Graph_Frequencies(); //delay(50);

Read_Buttons();

makeTurntableMove ();

makePendulumMove ();

} /*******************read the buttoms *****************************/ void Read_Buttons () { buttonStateLeft = digitalRead(pushButtonLeft); buttonStateRight = digitalRead(pushButtonRight); }

/*******************Turntable motor controls*****************************/

void makeTurntableMove () { TMotorSpeed = map(Frequencies_One[3], 0, 1023, 0, 255); //calculate turntable motor speed if (TMotorSpeed < 50) { //if motor speed is too slow turn it off TMotorSpeed = 0; }

analogWrite (enA, TMotorSpeed); //apply motor speed to turntable motor

if (Frequencies_One[1] > Frequencies_One[2]) { TMotorClock(); // compare frequencies to choose anti or clockwise } else { TMotorAnti(); }

// PMotorSpeed=map(Frequencies_One[6],0,1023,0,255); // analogWrite (enA, PMotorSpeed); }

// direction of the motor from the H Bridge void TMotorAnti() { digitalWrite(in1, LOW); digitalWrite(in2, HIGH); }

// direction of the motor from the H Bridge void TMotorClock() { digitalWrite(in1, HIGH); digitalWrite(in2, LOW); }

/*******************Pendulum motor controls*****************************/ void makePendulumMove () { // PMotorSpeed = map(Frequencies_One[6], 0, 1023, 0, 255); //calculate turntable motor speed

if (Frequencies_One[6] > 300) { PMotorSpeed = 100; } else { PMotorSpeed = 0; }

/*******************this is the bit that will control the switches and it needs to be sorted out*****************************/ // if the pendulum is at the top of the holder then don't go left any more // if the pendulum is too close to the base don't go right any more

analogWrite (enB, PMotorSpeed); //apply motor speed to pendulum motor

if (buttonStateLeft == LOW) { PMotorClock();

} else if (buttonStateRight == LOW) { PMotorAnti(); }

else { if (Frequencies_One[4] > Frequencies_One[5]) { PMotorClock(); // compare frequencies to choose anti or clockwise } else { PMotorAnti(); } }

// PMotorSpeed=map(Frequencies_One[6],0,1023,0,255); // analogWrite (enA, PMotorSpeed); } // direction of the pendulum motor from the H Bridge void PMotorClock() { digitalWrite(in3, LOW); digitalWrite(in4, HIGH); }

// direction of the motor from the H Bridge void PMotorAnti() { digitalWrite(in3, HIGH); digitalWrite(in4, LOW); }

/*******************Pull frquencies from Spectrum Shield********************/ void Read_Frequencies() { Serial.print(1023); Serial.print("\t"); Serial.print(0); Serial.print("\t"); //Read frequencies for each band for (freq_amp = 0; freq_amp < 7; freq_amp++) { Frequencies_One[freq_amp] = analogRead(DC_One); Frequencies_Two[freq_amp] = analogRead(DC_Two); digitalWrite(STROBE, HIGH); digitalWrite(STROBE, LOW);

Serial.print(Frequencies_One[freq_amp]); Serial.print("\t"); } Serial.println(); }

// int potValue = analogRead(A0); // Read potentiometer value // int pwmOutput = map(potValue, 0, 1023, 0 , 255); // Map the potentiometer value from 0 to 255 // analogWrite(enA, pwmOutput); // Send PWM signal to L298N Enable pin

Step 2: The Machine

Development of the Drawing Machine
The machine was prototyped in low fidelity materials, upgraded and refined as testing dictated. It is built from plywood circles from an industrial cable drum and chunks of scrap timber. The electronics are housed in a plastic sandwich box. The metal pendulum holder was initially from scrap metal tube held in place with a scrap brass pin. This was replaced with a taller wooden gallows. The idea was to start prototyping using found materials as much as possible. Eventually the whole machine could be condensed into a smaller and more elegant container. The priority with this project was to get it working.

Upper Gear
Prototyped in cardboard to identify spacing initially. The upper gear went through a series of laser cut variations. These slipped and the teeth pushed away from the turntable pegs so the final gear is also made with dowel pegs. To stop it slipping on the motor shaft there is an aluminium mounting hub that screws into the gear and into the flat side of the motor shaft. Teeth continued to slip so eventually I cut out every alternate one.

The Turntable
Based on an IKEA Lazy Susan with wooden dowelling pegs evenly spaced and embedded into the underside. Starting with a premade turntable with a good set of bearings cut some of the prototyping time. Originally the pegs dragged a little on the uneven surface of the plywood bed. Raising the base with washers gave the space needed. The turntable is screwed into a laser cut base that fits into the top of the machine bed. This is so that it can be removed for cleaning.

Pendulum carrier
Originally bent steel tubing with 2 holes. The first for the cable and the second for fixing. The machine needed to be portable so the metal arch can be removed for transportation. There is a brass pin to stop the carrier from moving side to side. The round curve of the steel stopped the pendulum from rising and falling freely. I tried plastic string, picture wire and nylon cord. Nylon cord was most successful. Replaced with a wooden gallows held in place with a wooden frame in the base. This can be removed. Eyelets up the side of the gallows hold the pendulum string in place.

Step 3: The Tech

Powering the machine
Both geared motors are 12V reversible high torque with a load of 10KG.CM and a variable speed between 0.6-120RPM. Upper Motor The upper motor is underneath the bed of the machine and held in place with a brass plate, screwed into the motor and into the wooden bed. The motors are strong and need securely fixing into place so they move what is intended only. 2 wires from the motor run into a H Bridge motor controller. Lower Motor This is attached to a wooden upright underneath the bed of the machine with bent aluminium. It carries a spindle made from laser cut ply attached with an aluminium mounting hub.

Spectrum shield
This fits on top of the Arduino and works as a graphic equaliser, identifying frequencies. The generally accepted standard range of audible frequencies for humans is 20 to 20,000 Hz, The shield can split audio input into 7 bands per channel 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz, 16kHz Can read amplitude of each channel using ADC on Arduino Analog pins - 0 is the DC output from the first IC. Analog 1 is the DC output from the second. Control pins - Strobe and reset - D4 and D5 For strobe pull reset pin to LOW. To reset entire multiplexer pull reset pin to HIGH. Strobe pin cycles through each channel starting at 63Hz. Audio in is the mic (may be easier with a ADMP-401 MEMS microphone $10.95 Audio out will control movement Read Frequencies steps through each frequency band, reading the DC values output and storing them in predetermined frequency arrays. Graph Frequencies function drives things based on the frequencies being read by the spectrum shield.

Dual-channel H-bridge driver. Can drive one 2-phase stepper motor, one 4-phase stepper motor or two DC motors.