Kit per una scultura vivente

Preview:

DESCRIPTION

costruire sculture viventi con arduino

Citation preview

KIT PER UNASCULTURAVIVENTE

materiale occorrente

arduino uno

wave shield for arduino

materiale occorrente

arduino breadboard

arduino cavetti

materiale occorrente

accelerometro

scheda sd 1gb

materiale occorrente

cavo usb dati /alimentazione

computer

materiale occorrente

http://arduino.cc/en/main/software

http://code.google.com/p/wavehc/downloads/list

http://ge.tt/48uu96e?c

materiale occorrente

casse non alimentate

cavo di alimentazione dav batteria 9v

batteria 9v

materiale occorrente

cartone pressato 4mm

matita

cutter

materiale occorrente

trapano punte da ferro

spago

materiale occorrente

portavasi zincato socker ikea diametro 27cm

http://www.ikea.com/it/it/catalog/products/30155670/

materiale occorrente

montaggio

montaggio

1.Download

montaggio

2.

montaggio

3.Installazione Software Arduino

montaggio

4.

librerie

montaggio

5.

montaggio

6.

7.

montaggio

8.

C

A

D

E

D

C

B

AB E

montaggio

9.Aprire un nuovo sketch

* codice

montaggio

10.Codice*

/* * Adafruit SampleRateMod.pde example modified to use WaveHC. * * Play files with sample rate controlled by voltage on analog pin zero. */#include <WaveHC.h>#include <WaveUtil.h> SdReader card; // This object holds the information for the cardFatVolume vol; // This holds the information for the partition on the cardFatReader root; // This holds the information for the volumes root directoryFatReader file; // This object represent the WAV fileWaveHC wave; // This is the only wave (audio) object, since we will only play one at a time /* * Define macro to put error messages in flash memory */#define error(msg) error_P(PSTR(msg)) //////////////////////////////////// SETUPvoid setup() { Serial.begin(9600); Serial.println(“Wave test!”); // try card.init(true) if errors occur on V1.0 Wave Shield if (!card.init()) { error(“Card init. failed!”); } // enable optimize read - some cards may timeout card.partialBlockRead(true); if (!vol.init(card)) { error(“No partition!”); }

montaggio

if (!root.openRoot(vol)) { error(“Couldn’t open root”); } putstring_nl(“Files found:”); root.ls();} // forward declaritionvoid playcomplete(FatReader &file); //////////////////////////////////// LOOPvoid loop() { uint8_t i, r; char c, name[15]; dir_t dir; root.rewind(); // scroll through the files in the directory while (root.readDir(dir) > 0) { // only play .WAV files if (!strncmp_P((char *)&dir.name[8]. PSTR(“WAV”))) continue; if (!file.open(vol, dir)){ putstring(“Can’t open “); printEntryName(dir); Serial.println(); continue; } putstring(“\n\rPlaying “); printEntryName(dir); Serial.println(); playcomplete(file); file.close(); }}/////////////////////////////////// HELPERS/* * print error message and halt */void error_P(const char *str) { PgmPrint(“Error: “);

montaggio

SerialPrint_P(str); sdErrorCheck(); while(1);}/* * print error message and halt if SD I/O error, great for debugging! */void sdErrorCheck(void) { if (!card.errorCode()) return; PgmPrint(“\r\nSD I/O error: “); Serial.print(card.errorCode(), HEX); PgmPrint(“, “); Serial.println(card.errorData(), HEX); while(1);}int16_t lastpotval = 0;#define HYSTERESIS 3/* * play file with sample rate changes */void playcomplete(FatReader &file) { int16_t potval; uint32_t newsamplerate; if (!wave.create(file)) { putstring_nl(“ Not a valid WAV”); return; } // ok time to play! wave.play(); while (wave.isplaying) { potval = analogRead(0); if ( ((potval - lastpotval) > HYSTERESIS) || ((lastpotval - potval) > HYSTER-ESIS)) { putstring(“pot = “); Serial.println(potval, DEC); putstring(“tickspersam = “); Serial.print(wave.dwSamplesPerSec, DEC); putstring(“ -> “); newsamplerate = wave.dwSamplesPerSec; newsamplerate *= potval;

montaggio

newsamplerate /= 512; // we want to ‘split’ between sped up and slowed down. if ((potval > 330) && (potval < 350)) { //potval legge il valore x dell’accelerometro newsamplerate = 24000; // se l’acc. è fermo allora fa par-tire il file wave wave.play(); Serial.print(potval, DEC); } else { // altrimenti se si inclina a destra o sinistra si interrompe newsamplerate = 1000; //24000; wave.pause(); Serial.print(potval, DEC); } wave.setSampleRate(newsamplerate); Serial.println(newsamplerate, DEC); lastpotval = potval; } delay(100); } sdErrorCheck();}

montaggio

11.Upload

Spegnere il computer, scollegare il cavo usb.

montaggio

12.

montaggio

13.

montaggio

14.

montaggio

15.

montaggio

16.

X 12

8 CM

0,5 CM

montaggio

17.

montaggio

18.

montaggio

19.

montaggio

20.

CREDITSwww.leraneacide-portfolio.tumblr.com / www.puccimarco.com / www.ladyada.net

Recommended