How to Make a Painting Play Music

by acruz4044 in Circuits > Art

455 Views, 3 Favorites, 0 Comments

How to Make a Painting Play Music

IMG_4017[1].JPG

Have you ever wondered how to make a painting that can make music?

Well if you have or haven't, here is how to make a painting that can play music!

The materials you will need are:

- Painting canvas (make sure there is plenty of space in the back to put all the electronics in)

- Paint/paintbrushes

- Conductive paint (can be found on amazon)

- Hammer and nails (use the smallest nails you can find, as long as they stick out from the back and don't get in the wood)

- Arduino board

- 500K to 1M resistor

- 220ohm resistor

- Foil

- Plastic wrap

- Jumper wire

- Copper tape

- Copper wire

- Small cardboard box

- Breadboard

- Battery

- USB cable

- MIDI to USB cable

- MIDI connector

- Digi-key connector receptical

- Tape

- Computer

Create Your Painting

IMG_3918.JPG
painting.PNG

For this step, you'll need your canvas, paint brushes, paint, and conductive paint.

This step is considered the easiest. All you need to do is use your creativity and come up with an idea of what you want to paint. Remember you have to make sure you know how you're going to use the conductive paint!! If you forget to use the paint, then your painting won't be able to make any sound when you touch it!!

If you are not someone who can be creative, here are a few other ideas you can use!

- Cow print painting

- Giraffe print painting

- Cats with black cats painted with the conductive paint

Before you move on to the next step, make sure the spots you use the conductive paint that the spots are painted thickly and avoid watering down the conductive paint.

Make sure to also plan out the layout of your painting so you have an idea of what you want the back of the painting to be like. For example, I 3D modeled where I wanted all of the materials to go in the back. The blue shape represents the canvas, the brown represents the cardboard box that will contain the aluminum foil, the green represents the placement of the Arduino, and the gray represents where the rest of the wires and materials will go.

Connecting the Conductive Paint

IMG_3926.JPG

Once your painting has dried and you have painted all the spots where the conductive paint is going to be, get your nails and hammer. Take the nails and poke them through the canvas in the areas there is conductive paint. If poking them through is too difficult, make sure you use the hammer and hit the nails very lightly.

When touching the painting, you will not need to touch only the nail heads. Touching anywhere along the conductive paint will allow for the painting to produce sound. The nails will only create a solid connection between the paint and the electronics.

After nailing, you can go over the nail heads in conductive paint if you wish, but it's not needed for functionality. Once done, turn the canvas over and get the copper wire and copper tape. Get a strand of the copper wire and tie some of it around the nail. Then get a large strand of copper tape and secure the nail and copper wire to the canvas. Make sure to do this for every nail and that they are all secured properly.

Aluminum Foil

IMG_3921.JPG

For this step get a piece of aluminum foil, big enough to fit in the cardboard box, and cut it. Then get a bigger piece of plastic wrap and cut it. Use the plastic wrap to cover all around the piece of aluminum foil and tape it together. Make sure the plastic wrap is secured properly so that no wires will fall out.

After cutting and securing both pieces together properly, put the piece in the cardboard box. Next, put all the loose copper wires that are attached to the nails into the plastic wrap. Make sure that they are touching the aluminum foil. Putting the wires into the plastic wrap will secure them and will allow for the signal of the paint being touched to travel to the Arduino.

Capacitive Touch Sensor

IMG_3922.JPG
IMG_3924.JPG

For this step, you will need the breadboard, jumper wire, Arduino, and the resistor. Take three jumper wires and connect them to your bread board. Two wires will need to be placed in the same column and the other will need to be in a separate column than the others, but horizontal to one of the other jumper wires. Make sure to put the reistor in both of the columns you end up choosing. Next take the jumper wire that is in a different column and plug it into terminal 1TX on the Arduino. Next take the wire horizontal to it and plug it into terminal 2, it should be right above 1TX. Lastly, take the last jumper wire and plug it into the aluminum foil and plastic wrap.

Put Everything Together

IMG_1818.JPG

The last step is simply setting up the speakers. For this step, you will need a battery, 4 jumper wires, Digi-key, and the MIDI connector. Take the battery and connect two jumper wires to the positive and negative. Once finished, connect the other side to the digi-key. Next, take the other two jumper wires and connect one into one of the CND and the other to the other CND on the Arudino. Lastly, take the MIDI connector and plug it into the digi-key. Now take the USB to the MIDI adaptor and plug it into the Arduino. Connect the USB to your computer and copy the code below. After all of that is done, you can take all of the components and put them into the back of the canvas. To secure all of the materials inside, you can use tape and put it across the back of the canvas. Now you are finished and your musical painting is complete!

Code by sab-art

int bounceThreshold = 0; // a press must last this many loop cycles (about 20ms each) before triggering.

// higher values make it less sensitive, fewer false triggers, higher latency

#define NUM_INPUTS 44

int channel = 1;

// edit this array to change the MIDI notes sent

//int pitches[NUM_INPUTS] = {

// 79, 84, 75, 67, 65, 63, // top of board (up, left, down, right, space, click)

// 60, 62, 77, 68, 58, 56, // left side of female header, w,a,s,d,f,g

// 51, 53, 48, 55, 72, 74 // right side of female header, up,down,left,right,left-click,right-click

//};

// teensy makey pin numbers int

pinNumbers[NUM_INPUTS] = {

0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17, // left side starting at USB connector, pin D0, skipping D6

26,25,24,23,22,21,20,19,18,38,39,40,41,42,43,44,45, // right side starting at USB connector, pin B6, skipping gnd and aref

36,37,32,33,34,35,28,29,30,31 // these are "interior" through-holes, in the center of the board

};

// cap sense thresholds for each pin

// this is proportional to the capacitance on the pin that will count as a press

// it is units of a very small unit of time, in iterations through an unrolled loop

// higher values make it less sensitive (i.e. require larger capacitance)

//int capThresholds[NUM_INPUTS] = {

// 1, 1, 1, 1, 1, 2,

// 2, 2, 1, 1, 1, 1,

// 2, 1, 1, 1, 1, 1,

//};

int bounceCounter[NUM_INPUTS];

boolean pressed[NUM_INPUTS];

void setup(){

for (int i=0; i

void loop() {

for (int i=0; i1){ // if we detect a touch on the pin

if (!pressed[i]) { // and if we're not already pressed

bounceCounter[i]++; // increment the bounce counter

if(bounceCounter[i] > bounceThreshold){ // if we're over the bounce threshold

usbMIDI.sendNoteOn(60+i,127,channel); // send a MIDI note on

pressed[i] = true; // remember it was pressed

bounceCounter[i]=0; // reset the bounce counter

}

}

}

else { // if we don't a detect touch on the pin

if (pressed[i]) { // if this key was pressed before

usbMIDI.sendNoteOff(60+i,127,channel); // send a MIDI

note off pressed[i] = false; // remember we are not pressed

bounceCounter[i] = 0; // reset the bounce counter

}

}

}

//Serial.println(" ");

}

// CapacitiveSensor tutorial from http://www.arduino.cc/playground/Code/CapacitiveS... // readCapacitivePin

// Input: Arduino pin number

// Output: A number, from 0 to 17 expressing

// how much capacitance is on the pin

// When you touch the pin, or whatever you have

// attached to it, the number will get higher

uint8_t readCapacitivePin(int pinToMeasure) {

// Variables used to translate from Arduino to AVR pin naming

volatile uint8_t* port;

volatile uint8_t* ddr;

volatile uint8_t* pin;

// Here we translate the input pin number from

// Arduino pin number to the AVR PORT, PIN, DDR,

// and which bit of those registers we care about.

byte bitmask;

port = portOutputRegister(digitalPinToPort(pinToMeasure));

ddr = portModeRegister(digitalPinToPort(pinToMeasure));

bitmask = digitalPinToBitMask(pinToMeasure);

pin = portInputRegister(digitalPinToPort(pinToMeasure));

// Discharge the pin first by setting it low and output

*port &= ~(bitmask);

*ddr |= bitmask; delay(1);

// Make the pin an input with the internal pull-up on

*ddr &= ~(bitmask);

*port |= bitmask;

// Now see how long the pin to get pulled up. This manual unrolling of the loop

// decreases the number of hardware cycles between each read of the pin,

// thus increasing sensitivity. uint8_t cycles = 17;

if (*pin & bitmask) {

cycles = 0;

}

else if (*pin & bitmask) {

cycles = 1;

}

else if (*pin & bitmask) {

cycles = 2;

}

else if (*pin & bitmask) {

cycles = 3;

}

else if (*pin & bitmask) {

cycles = 4;

}

else if (*pin & bitmask) {

cycles = 5;

}

else if (*pin & bitmask) {

cycles = 6;

}

else if (*pin & bitmask) {

cycles = 7;

}

else if (*pin & bitmask)

{ cycles = 8;

}

else if (*pin & bitmask) {

cycles = 9;

}

else if (*pin & bitmask) {

cycles = 10;

}

else if (*pin & bitmask) {

cycles = 11;

}

else if (*pin & bitmask) {

cycles = 12;

}

else if (*pin & bitmask) {

cycles = 13;

}

else if (*pin & bitmask) {

cycles = 14;

}

else if (*pin & bitmask) {

cycles = 15;

}

else if (*pin & bitmask) {

cycles = 16;

}

// Discharge the pin again by setting it low and output

// It's important to leave the pins low if you want to

// be able to touch more than 1 sensor at a time - if

// the sensor is left pulled high, when you touch

// two sensors, your body will transfer the charge between

// sensors.

*port &= ~(bitmask);

*ddr |= bitmask;

return cycles;

}