PComp Final Project Progress 3

Now, we are making progresses!

As for the table, Sid made the great work like the below!!!


IMG_8410

And Nick made all the great 8 songs for 8 objects now!

And here below is the progress in the coding side (Arduino & p5.sketch, serial communications) now… though it’s still a bit unstable, I am now getting more and more familiar with how the capacity changes according to the things and environments.
*I actually had some hard time in controlling multiple things!

I am now setting the threstholds by calculating the averages of the first 10 / 20 seconds capacities of each (without touching these), and also setting some time lag in looping in the Arduino so that they don’t somehow rush too much in doing these and end up in failing to get them.



As you can see, it’s still unstable and the stone song starts to play again and again at the end… It may be because I somehow touched the wire of it or the environment around changed somehow.

Well, by seeing the below, I think you can see how greatly the capacity changes by touching it (this time, “silk”). We are using this BIG difference in capacities to catch their touching it (or being closer to it).

The numbers on the screen is:

– performance time (time it spends to do one loop),
– the capacity it reads,
– the number it reads,
– the average of its reading so far (by 20 seconds),
– the threshold based on the average (like 4 times of its average)



And we already had 4 boxes prepared (gourd, stone, metal(somehow), and silk).
The gourd is the most difficult thing to get the great capacity change by touching it but I think it’s now somehow working in a way…



Here below has some bugs (unstableness) but just as a reference, I am also presenting this here…



My idea now is to update the thresholds by calculating the average of their capacities again per 3 minutes or so… as well as setting the remote control to reset them just in case.
But during those 10 seconds, people should not touch any things and that’s where I am now wondering how to let them know that…
Also, we have to work more on visualization part tomorrow!, as well as preparing 4 more boxes (tree / clay / leather / bamboo).

We are a bit behind but I am sure and looking really forward to having this project completed by this Thu., final PComp class!!! and showing this interactive installation successfully at ITP winter show!

Thank you.

Sachiko Nakajima, Dec. 10th, 2018

Pcomp Final Project Progress (mid Nov.)

This article was originally written in mid Nov., though I forgot to publish it!
Sorry…

————
Now, this is the documentation of our final Pcomp Project.
This time, we, Nick, Sid and me have got the idea of “8 SOUND with 8 BONSAIs” for our final project.
8 sounds are Chinese traditional ways to classify the instruments:

tree (木), stone(石), clay(土), metal(金属), bamboo(竹), string(弦、絹), reed(瓢箪), leather(皮)

We would like people to know these traditional Asian ways to view music instruments as natural things around, and to feel the sounds from those around us in various ways, without any professional skills to play those instruments.

So, we had got the idea to make a beautiful cultural (eastern Asian) art installation with 8 bonsais, which can generate the aesthetic sound(s) by touching them as well as visualizing it in the center plate with white sands, like the below!

First sketch by Nick in the class, inspired by our ideas (Sachiko and SJ):



And here below is the revised sketch by Nick! based on the 8 directions in Chinese traditional ways:





And here below is the Sid’s revision by 3D image:



To make the sounds by touching them, we made some experiments with capacitive library in Arduino playground.

Here is the work with tree surrounded by the metal conductive wire, which can turn on the LED by touching it.
*The circuit is really simple. The resistor connects Arduino pin 2 and 4 and at pin 2, the wire is also connected. To turn on LED, I set the pin 7 OUTPUT and connected the LED and the resistor to pin 7 and the ground. On the serial monitor, you can see the capacity numbers changing greatly by touching it.
*I set the minimum capacity as 5000 to turn on the LED.



And I changed the LED part to the speaker…



And changed the branch into the stone:



And also, we tried to make 2 similar things by one Arduino. Pin 4 as an output, pin 2 to the stone1, and pin 6 for the stone2.
*I mapped the capacity into the frequency.



Isn’t it like the singing mysterious stones? I liked this:)

However, in order to have the clear visualization by white sands in the center, we are thinking to use just one song (simple one) for one thing, so that we can have sorts of stable visualization, which is based on the plate’s own unique frequency (solutions of differential equations).

Here below is our test samples of visualization by white sugar…
Though it’s not yet good enough, you can see the rough sketch of our plans, I suppose…



Thank you!

Best,

Sachiko Nakajima, Nov. 15th, 2018

Pcomp final project brainstorming…

As I am a jazz pianist and I am interested in “translating some sense into other sense (e.g. among: visual / audible / haptics…)”, I am now having some ideas about

– translating some physical motions on very natural daily things into some audible sounds / tones (Part I)
– making DJ music by touching some physical things around (Part II)

As for Part I, I also would like people to experience “sounds/tones” through daily things as well as to interact with music through those experiences even if they are not so-called professional musicians.

More concretely, I have 4 ideas which I have to polish more, as for Part I!

[ Part I ideas ]

1) water drop instrument:
when you drop the water drops from the beautiful syringe (made by bamboo?) on the plane (or a big leaf), it causes some beautiful sound and light, based on the position of that.
Not only that, I would like to make some images (beautiful water drops) appear on the screen “leaf” (p5) there possibly.

— > can I sense the position of the water there? Can I divide the plane (put on the floor, which hides the circuits under) into grids, each of which has the sensor to sense if that grid is humid or not? … (at least 16 humid sensors and 16 LEDs!? Can I control this by a big one board with 16 inputs and outputs?)
If it’s stone-putting, could the sensors be touch sensors?

2) glittering stone instrument:
Here is the example of my ideas in my head:

For example, when you stroke the part of the stone gently, it changes the tones depending on where you touch and make some sounds based on that (analog output) as well as changing colors on the stone

(I am not sure how to change colors as of now… possibly using the MAX? if difficult, it could be changing which LEDs to be on based on the current as well as how much it glitters)

3) interactive installation with sound and lights:
sending IR signals by cellular phones(?) so that
– it could turn on some LEDs instantly like a light wave,
– it could generate the moving flower or flake of snow on the screen (p5), which would also float on their phones (?),
– it could make beautiful tones when it appears and when it collides with other flower / snows (p5 side). ( I think it could be done by IR transmitter and receiver by some protocol! with just one board receiving IR signals, serial-communicating with p5)

4) interactive mathematical strings instruments:
Just like the below! Needs ”MAX”???

——————————

Or… I have another ideas about 3D Kagura as Part II idea.
“Kagura” is the kind of famous music applications made by Shikumi Design (Japanese Company).
It generates the synthesized music (with the same BPM) when you touch some objects (you can draw that objects on the pad) on the projector.

KAGURA (Shikumi Design)

–> The hidden key to generate real cool MUSIC by this is quite simple! (just to synthesize beats for each) so I am wondering if I could make any similar things with physical 3d things. This could be my Part II idea.

e.g. touching/hitting various stones or balloons around, it generates the “synthesized” music with the sound of different musical instruments of each

Something like this? (TEAM LAB “Sound of Life”)

Other Inspirations

This idea could be easier!? than those 1)2)3), but not so sure…(possibly using force sensors. If its value gets higher than some value, it generates the tone (based on the position) with “synthesized” BPM.

If the master board controls each stone by radio, I think it could be realized like
A) first sense the force power –> B) send the signal to the master / master receives the data –> C) master always has the constant hidden beat and master generates the sound based on that beat while the master receives the data from the stone(s)

Of course, I know it would be really difficult to control radio communications without Rui’s help, I feel like trying…

I am still not yet determined of which I should focus on, but just to share my ideas now in advance…

Best,

Sachiko Nakajima, Nov. 8th, 2018

PComp MidTerm Project!!!

NOW… we welcomed Midterm PCOMP Project!
First, please see our delights! when we somehow succeeded our partial ideas at the midnight just before the presentation…

Well, our team consisted of 3 members, a young amazing Chinesen C++ programmer Rui, an inspiring Brazilian “stage light” artist Marcela, and me (Japanese jazz pianist / mathematician / STEAM educator).

First we got together to discuss our ideas and we finally agreed on some rather “big” story, which could be fun and heart-warming rather than scary.
Our idea was to put “life (heartbeat)” to the lonely skelton collaboratively by putting the bones with each of their heartbeat.
Even though the skelton seems to be “dead” and scary, we though that even skelton could be playful with “life” on Halloween day!
(We got the inspiration from the movie “COCO”!)

To realize our ideas,
1) we had to use “radio” communications to control multiple boards from the distance by the master board
2) we had to show our data (heartbeat) on the screen so that they could know (possibly with sound)
3) we had to have “BEAUTIFULLY” made bone with LEDs inside, so that LEDs would be lighted on and off according to the heartbeat obtained by heartbeat sensor.

Our idea how people would interact with bones in our project was as the following:

====================
1) First, push the switch button to start to obtain his/her heartbeat by heartbeat (activate the bone board:send and the master board:receive)
2) Put your finger gently on the heart sensor connected to the circuit with the switch and bone board (send analog inputs to the bone board and send that data by radio to the master board)
3) Once you get the enough stable data, the master board says to the bone board to stop getting the data from the heartbeat sensor (the master stop receiving the data from the bone board)
4) The master board starts to send the heartbeat signal to the appropriate bone board so that that bone LED starts to blink based on that
5) Once the bone is connected to the body somehow in the appropriate order, through the connection part, the master somehow gets to know that it’s connected and the master board starts serial communications with p5.js on the computer in the distance
6) The screen starts to show the data with the bone blinking based on that, while the heart(real one and the screen heart) starts to blink based on the data so far…
7) Once we get all the necessary bones connected to the body, the heart would blink beautifully with LED stripes based on the average of all the heartbeat data and the screen tells you that the project (to give life to the skelton) is now 100% completed!
====================

This project somehow could be called “Your Heart Beats in Me” or “Give Life to the Lonely Skelton by constructing him all together”.

So, first, Rui did an awesome work on making the draft codes (C++) to control multiple boards form the distance by radio communications (using radio transmitter and receiver) and we did some tests to debug.
Here below, you can find the completed all the codes!
The Codes are all here to be found!

But as you may see, there were lots of hurdles here, which we would like to share with you.
The below is the brief talk about the process of creating the wireless communication between boards using a master-slaves network (by Rui).

The first chip that Rui bought was a ESP8266 WIFI chip. It soon turned out that the chip was not suited for our project purpose. Certainly, the chip could definitely accomplish our goal of wireless communication but it also had so many other functionalities that can only cause us troubles instead of providing assistance to achieve our goal. The concept of overkill doesn’t apply in projects involving hardwares. For all the things we learned from doing this project, this one definitely stands out the most.

Then Rui bought nRF24L01 chip. We don’t have much to say about this chip. It just sucks. For anyone who wants to do simple wireless communications between Arduinos, don’t buy nRF24L01.

Finally, Rui bought RF Link Transmitter/Receiver module pair. We are not trying to plug this product, but, THIS MODULE IS AWESOME. It is super easy to set up. There is no need for steppers and capacitors and most importantly the virtual wire and the radio head library are just super well documented.

For the software side, Rui wrote a simple protocol for master-slave communication, treating each message like a packet in a network protocol. The first bit represents the receiver ID, the rest is the actual content of user’s heartbeat.
Rui used openFrameworks to program the visualization of user’s heartbeats with a particle system that he wrote for his daily sketches.

———————-

Next, as for the connection part, Marcela found one good library called “PJON”, which can allow us to send the different signal from multiple boards with just 1 (or 2) wires.
PJON wiki (gitHub)


We actually succeeded our test! to have 2 different signals “A” and “B” from 2 boards by connecting just 1 wire (using 12 digital output and had the common ground at the end).
Here below, you can see two LEDs are blinking based on different signals “A” and “B” from different 2 boards, by just basically connecting the digital pin 12 with wires.It seemed awesome! and we were happy to succeed in this test at that time…….


======================-

Then, we finally started our fabrications part on bone and the heart.
We decided to use card-boards with holes for the inside of the bone, and use translucent acrylics.
Marcela did really great works on these… Here below are some of our process-photos.
*We used the razor cutter to make the bones.





The circuit is quite simple!
We used LED stripes (with 1 wire to 5V, 1 wire to digital pin 7, and 1 wire to the ground) and used 3 wires from the radio transmitter&receiver, each of which is connected to 5V, analog input A0, and the ground respectively.

The schematic circuit diagram could be just as follows for these parts.

– 5 Arduinos: master / bone1(arm up) / bone 2(arm down) / bone 3(hand) / heartbeat sensing board.
– 3 radio transmitter & receivers
– 1 heartbeat sensor (cheap one!)
– digital input circuit with switch
– 3 LED strips for 3 bones



*Here, it does not have the bone connection part (which were prepared but failed to use at the end…).
It’s just for “switch” / “heartbeat sensing” / “heartbeat transmitting to the bone” / “heartbeat transmitting to the screen (p5)”
*We were also thinking to connect the digital inputs and the ground of different boards (for each bone), by using the battery connection part as you can see in the photo.

As you can see in the circuit and the code “transmitter”, once the digital input “7” has the signal ON at the heartbeat sensing board, the state “record_heartbeat” turns into “true” and the board starts to send the analog input A0 signals (heartbeat) to the master.
Once the master get enough data, it changes the status “record_heartbeat” to be false and stop receiving the data. Instead, the master sends that data to the bone 1/2/3 (in order!) so that the bone in charge would start to blink beautifully based on that BPM.

Also, the master sends the same data to the p5.editor so that the data could be shown on the screen like the below.
*The first one is the first image of the skelton, but once they get the data it would be changed something like the below that.

Click here to see the initial screen

————-
Well, as our tests for the radio communication part and PJON communication part, we thought it should be OK to integrate these, as well as using serial communications to show the data on the screen.

However, IT WAS NOT OK!!!…

On the very last night before our P-Comp class, at the last stage of combining everything, Rui found that PJON and radio communications cannot “coexist” somehow…OH NO!!! …

So, we came up with the idea of realizing heart blinking part physically, but at the end of the day, we could not do that heart part, which could be the most important part though…

Actually, even for the radio communications and serial communications between the master board and p5 editor had some trouble with uncertain reasons sometimes… (it may be just because communications were a bit unstable???). But finally at 3AM, we did succeed!!!

Here below is kind of the proof that our radio communications to control multiple boards and our serial communications between master board and p5 editor did succeed all at the distance!
(The same one shown in the top)

In the one below, someone serial communications to the screen is not working but I think you can enjoy more of the beautiful bone blinkings!

……….
Anyway, we did a lot!!! for this project really. Although we failed in the connection part to make the heart blinking based on the data gathered physically, I feel very much honored to collaborate with great inspirational members, Rui and Marcela!!!

We could overcome various hurdles and experienced the hardships (including our failures).

I myself would like to go further on this way. The multiple board control by radio and the fabrication part, as well as serial communications could be really useful for our future.

Thank you again!!! for my great members and great & kind support by Jeff! as well as those who struggled in the mid-term projects as well!
I am so excited and thrilled to go further on these pcomp projects!!!
(Sorry for being really late in submitting this documentations.)

Sachiko Nakajima, Oct. 31st, 2018

PComp Class 6 Assignment -Serial Communications between Arduino and p5!-

This week so far was so crazy, going back to Japan and having 3 online meetings with Japan even back in NY!
However, Jeff was sooo kind to spare me his valuable time on Mon. morning, and I think I am now almost 99% understandings what’s going on around the basic serial communications with Arduino and p5.

But the 1st step was not actually easy… I mistakenly uploaded a different js file (p5.serialserver.js) to p5, and got the error “p5.Serial Port is not a constructor” And even after I noticed my mistakes and replaced that with the correct js file under the correct name(“p5.serialport.js”), I am not sure why, but it kept saying this error!
(I did add correct lines to index.html, too.)
It seems p5.editor got annoyed to find the first strange file, and it kept something as a casch… After spending lots of time, I finally decided to start from the scratch with the totally same files… and it WORKED!
(except for “println” error –> changed to “print”)

I learned that sometimes, even with correct data, the PC could be stuck with old missing memories … and should be refreshed totally!

Anyway, once I got over this hurdle, everything went quite smoothly.
Here below are almost just following the instructions on “Lab: Serial Input to P5.js” (though revised a bit).
To review things, I would rewrite what I did below:

(1) made a simple Arduino circuit with a potentiometer and connected to PC
–> run the simple code like…

void setup() {Serial.begin(9600);}
void loop() { int potentiometer = analogRead(A0);
Serial.write(potentiometer/4);
delay(1);}

–> p5 Serial Control monitor showed all the possible serial port list! Arduino serial port is something like
/dev/cu.usbmodemXX (XX could be changed, 2 digit number)
–> if you see the signal on Arduino Serial Monitor, there are a bunch of strange letters like ?o_x%kjec…


 

(2) on p5.js.web editor, after adding p5.serialport.js and some notes in index.html, I put code on sketch.js:

var serial;
function setup() {
serial = new p5.SerialPort();
serial.on(‘list’, printList);
serial.list(); // list the serial ports}
function printList(portList) {
for (var i = 0; i < portList.length; i++) {
println(i + ” ” + portList[i]);}}

–> In the console, too, I could see the available serial ports! Yes!

(3) I used p5.serialport library, and set various callback functions to various events.
e.g.

serial.on(‘open’, portOpen); // callback for the port opening
serial.open(portName); // open a serial port
function portOpen() {print(‘the serial port opened.’)}
//define the callback function to do what in response to the event “open”

(4) after storing the serial value in inData (inData = Number(serial.read()); **NOTE that I changed the signal from strings to numbers), I put the function draw as below, and I could see the changing number, based on potentiometer’s change like the video below.
It means I could succeed in communications between Arduino and p5!

function draw() { background(0);fill(255); text(“sensor value: ” + inData, 30, 30);}

(5) Now, I made the graph of time & sent signals.
The p5.js code is like this!
See how it worked!

(6) If we change the Arduino code from serial.write to serial.println, and added print(inData) in the SerialEvent function, p5 reads the signals like this!

I think you could see 13 (carriage return, \r) and 10 (newline or \n) so often here!

(7) If we change the p5.js code like… function serialEvent() {inData = serial.readLine();}, it means it’s reading something like (6). So, the graph is somewhat discrete.

(8) Finally, if you change that like

let inString = serial.readLine(); // read a string from the serial port:
if (inString.length > 0 ) { // check to see that there’s actually a string there:
inData = Number(inString); // convert it to a number:}}

This means that we could get the sent data as original 10 byte!
I think you could see that the graph is more far smoother than before.

————————
*I could not succeed yet to use smartphone or other PC in serial communication!

Now, from here, I made a small original arrangement to these serial communications between Arduino and p5!

(9) using the sent data (based on potentiometer), I changed the size (and color) of the circle in the canvas.
*There are 2 versions. One is setting the background color in “setup” while the other, in “draw” function.
The code is here!

(10) Based on Jeff’s kind & great advice, I challenged one more! to have the additional analog input to be used in p5!
Here below is my circuit idea with potentiometer and force sensor, and Arduino code / p5.js code example.

I COULD SUCCEED IN SENDING 2 DIFFERENT ANALOG DATA SEPARATELY to p5.js using serial communications!!!

Arduino code is as below:

void setup() {
Serial.begin(9600); // initialize serial communications
}

void loop() {
int potentiometer = analogRead(A0);
int forcesensor = analogRead(A1);
int mappedPot = map(potentiometer, 0, 1023, 0, 255);
int mappedPot2 = map(forcesensor, 0, 1023, 0, 255);
Serial.println(mappedPot);
delay(1);
Serial.println(mappedPot2);
delay(1);
}

and p5.js code is here!

I think you can see the 2 signals are recognized almost 100% separately in p5.js, though I just put delay(1) in between potentiometer signal and force sensor signal.

……. I am now SO EXCITED to have physical(electrical) things communicating with PC!!!

Sachiko Nakajima, Oct. 17th, 2018

Class 5 PComp Assignment – review –

This week is set to review our learning on pcomp so far! Though first I felt difficulties to get used to electronics using Arduino, I think I am now able to understand what is going on and what to be done almost 99%! I think! I am now feeling confident and so excited to go forward with pcomp!

What I am not so used to it yet is about the details (reading the data sheet to know what kinds of characteristics each component has).

For example, I had some difficulties in using the temperature sensor and force sensor.

1) As for the temperature sensor, it got really hot in the circuit!, though I checked again and again if my circuit has nothing wrong…
Well, actually as I did not have the data sheet for that temperature sensor (which I bought at Tinkersphere), I actually googled the same temperature sensor and found that which pin is which, and I believed that I put the sensor legs in the right direction.

Here is the site I referred to: https://learn.adafruit.com/tmp36-temperature-sensor/overview

But I searched the similar issue related to this, I found that… sometimes the online datasheet could be wrong! Actually, it seems that some people did try (with courage! because it might damage the sensor if put in the wrong direction) to put the sensor legs in the opposite directions to the indications, and found everything went so smoothly, without getting so hot!
My case seems to be the same issue, for I did try the opposite directions to find that everything go smoothly…!!! without getting that hot!


*Here, I put the 5V and ground legs opposite to the indication shown on the site above.

Also, I found the official data sheet for this TMP36 and confirmed that the opposite way IS the correct way, indeed.
Official Data Sheet for TMP35/36/37
From this, I learned that the official data sheet is so important, but also some information on the web could be sometimes wrong or outdated somehow…

2) As for the force sensor, as I stated before, I did try to put big resistor like 10K and 20K Ohm (after force sensor and voltage divider to Arduino), but still the range of analog input from this force sensor was really low (below 100).
Again, I searched the similar issue on the internet but it seems that after all, the issue is caused by that the resistor could be still relatively too small… compared with the force sensor!

So, I again tried to put 100K/200K resistor to the ground (and connected to the force sensor, with voltage divider in between). Then, the range of analog input did expand!!! (finally to 142 when I put 200K Ohm)!




I learned that again, the data sheet could be so important (the sensor has various resistance inside!), and the characteristics are so varied.
Especially when deciding what OHM resistance to put in the circuit, these do matter.
I think I have to be more delicate and careful about the voltage, current and resistance amount when making the circuit.

Anyway, as I am feeling to be so accustomed to these physical computing and so excited to explore more of this world (thanks to Jeff’s kind and great introduction of various things!).
I feel really enjoyable, especially, that I could relate the physical things with coding!)

Though I have to be absent from the classes on ICM/PComp this week, I would like to catch up and explore more and more of these world!!!

Sachiko Nakajima, Oct. 9th, 2018

PComp Class 4 – Arduino MINI PIANO using Light Sensors (Japanese song “Rabbit”) –




– Japanese Traditional Song “Rabbit (USAGI USAGI)” played by Arduino Mini Piano, using 6 light sensors! –

This time, we are to use “(Pseudo) Analog Output”, using the code “AnalogWrite” (which uses PWM: Pulse Width Modulation, changing the portion of the time the signal on versus the time that the signal off, but not changing the frequency) or “Tone” (PWM: default 50%, but changing the frequency).

First, I used the servo Motor and the force sensor, and “analog output” to the servo motor, mapping the sensor change into the angle change of the servo like the below.
*Here, I had difficulties when using the stretch sensor / temperature sensor. As for the stretch sensor, even if I set the connected resistor low or high, I could not change the voltage so much when I stretch the stretch sensor strongly. As for the temperature sensor, it got really hot! and I was surprised to touch that when trying to change the temperature…



After this, I tried to use the light sensor to make a sound, and here I got the idea to make an easy mini-piano!
As Arduino has 6 analog inputs, and I have 6 light sensors, I put each of the light sensors to produce a note when it gets dark (by putting a finger on it).
*I checked one sensor value on the serial monitor and set the base number to make a note.

The top video in this post is the scene I played the Japanese traditional song “Rabbit (USAGI USAGI)” (for the moon festival season in September), by the Arduino Mini PIANO!
*This song is using just 6 notes: re, mi, fa, ra, ti, do and I set the tone frequency to be the JUST TONE ratio!, which is a bit different from the equal temperament. It’s SO easy to set any temperament using this!
(Actually, when recorded, I used the base tone “do” but here below, I rewrote the code to set the base note: ra 440 Hz.)
*My daughter helped me a lot! when making the “pseudo-piano”, for I am not so good at fabrications… But it really is fun to make these kinds of mini-instruments by ourselves with pretty playful shapes…

Please enjoy this Japanese-like song!!!


“USAGI USAGI NANI MITE HANERU
(Rabbit Rabbit, what do you see when jumping?)
JUUGOYA OTSUKISANN MITE HANERU
(When seeing the 15th-day Full Moon, I jump…)”

Fa – Fa Ra Ti Ra Ti – /
Fa -Fa Fa Ra Ti Ra Ti – /
Ra Ti Do Do Ti DoTi Ra Fa /
Ra Fa Mi – Fa Mi Re -/ Mi – – –

The circuit is like this and I also write the code as a reference below (though it’s soooo simple, compared with class 3 assignment work!)



——————
const int base = 25;
const int speakerPin = 8;
void setup() {
Serial.begin(9600);
}

void loop() {
int tone1 = analogRead(A0);
int tone2 = analogRead(A1);
int tone3 = analogRead(A2);
int tone4 = analogRead(A3);
int tone5 = analogRead(A4);
int tone6 = analogRead(A5);

int lowdo = 264; //440*3/5
int re = 293.3; //440*2/3
int mi = 330; //440*3/4
int fa = 352; //440*4/5
int sol = 391.1; //440*8/9
int ra = 440;
int ti = 495; //440*
int highdo = 528; //440*6/5

if(tone6<base){
tone(speakerPin,re,100);}
if(tone5<base){
tone(speakerPin,mi,100);}
if(tone4<base){
tone(speakerPin,fa,100);}
if(tone3<base){
tone(speakerPin,ra,100);}
if(tone2<base){
tone(speakerPin,ti,100);}
if(tone1<base){
tone(speakerPin,highdo,100);}

Serial.println(tone1);
delay(20);
}

*It’s pretty easy to change the notes to e.g. “do, re, mi, fa, sol, ra” to play the “twinkle twinkle little star”!

This was really a fun! and I would like to explore more of this Arduino’s inspiring world!

Sachiko Nakajima, Oct. 3rd, 2018

PComp Class 3 Work with Arduino!

This week’s PComp assignment was to create some interesting Arduino project, with analog input & digital output.
I happened to get IR (Infrared light) receiver and sound sensor at my hand, I tried to use them!

The projects below are what I have done after class3:
*FYI: IR light is invisible, but can be a bit felt as a heat by humans. IR radiations are really a lot around us, and for example, almost all the remote control (of TV, audio, projector…) are using IR to transmit some instructions.

– Arduino Project with IR receiver
and the projector remote control of our PComp classroom 🙂 – 

* This IR receiver has 3 legs: VCC, GROUND, OUTPUT

As you can see, super-interestingly, I could figure out what kinds of codes are emitted by this projector’s remote control, and based on that information, I could make codes to figure out what button was pushed, even though I don’t see the button! Isn’t it like a sort of magic!?
* I picked up 8 buttons there as samples: Power, Search, Computer, Video, USB, Center Button, Help!!!, and Freeeeeze!!! 🙂

Also, the input of IR is converted into digital signals at IR receiver, and I made Arduino to send those information out to control LED flash!

– Arduino Project with IR receiver,
the projector remote control of our PComp classroom, and 3 LEDs –

– If you push “Power”, the red LED turns ON.
– If you push “Help” button, the yellow LED turns ON.
– If you push “Freeze” button, the blue LED turns ON.
– and…If you push the center button, all the 3 LEDs turn ON!
*read the IR signals and convert those into digital electric power to turn LEDs on!

It really was fun to control “invisible” signals.
I also found that these kinds of IR signals are used in various places like TV, projectors, Air Conditioners, audio, …. at any kinds of remotely controlled machines. Actually, I found LED-like IR emitter embedded in the TV remote control at my house!


Now, I learned that each of these emitted IRs (about 38 kHz, rare frequency in the nature so that the IR receiver can recognize the signals) is assigned to some message like “Power” “Search” “Menu”… under some protocol by NEC, Toshiba, Hitachi,…
*The projector remote control of our PComp Classroom actually seems to be using NEC protocols.

So, I suppose, if the IR sent by the IR emitter on the remote control is received by the IR receiver, the machine would start to act according to the protocol (instructions) for that IR message.
This seems to be a kind of modern CODEs/steganography, invisible to human beings…
*That’s why sometimes it takes time if you are far away from the IR receiver, or your remote control is not directed to the IR receiver… (I tried various ways to put buttons on the TV remote control, and confirmed these!)

Also, with a sound sensor, I made a bit “club-like” dancing lights machine.

– Arduino Project with Sound Sensor
and the intro of my original song “SHAKUNETSU (scorching heat)” –

Actually, I wrote the code like the below:
First, define 4 integers: threshold1 < threshold2 < threshold3 < threshold4. Then,
1) If the sound volume is more than threshold4, all the 4 LEDs (RED/YELLOW/BLUE/GREEN) turn ON.
2) If the sound volume is between threshold3 and threshold4, only RED/YELLOW/BLUE LEDs turn ON.
3) If the sound volume is between threshold2 and threshold3, only RED/YELLOW LEDs turn ON.
4) If the sound volume is between threshold1 and threshold2, only RED LED turn ON.
5) If the sound volume is below threshold1, all the 4 LEDs turn OFF.

Sound Sensor has, like IR receiver, 3 legs: OUT, GROUND, VCC
This output signals would be INPUT to Arduino through A0 (and analogRead on the serial monitor), and would be OUTPUT through i.e. 6, 9, 11, 13 as voltage (electric power) to turn LEDs ON.

The difficulty here was… that the sound sensor is so delicate and unstable…
Every time I read the Arduino codes, the sound volume range somehow changes and it was really hard to determine the suitable threshold1/2/3/4 value. Also, how to control the LED ON/OFF by sound volume was also really tough!

Here in the video, I used a part of my original song called Shakunetsu (Scorching Heat) played by my jazz piano TRIO (Sachiko Nakajima: piano, Yasushi Yoneki: bass, Tamaya Honda: drums).
As you can see, sometimes, the LED motions just matches to the sound, but not always…

Anyway, for me, these projects were really really FUN!!!
But, honestly, I also had really hard time… because, Arduino seemed to be suddenly totally NOT WORKING today!!!

I checked all the details and various Arduino projects, searched the information, uninstall & reinstall… almost everything I could do. I thought that something serious happened to my Arduino (shorted!?)… and finally had the courage to ask Professor Daniel Rozin.

And… he kindly checked all the details and found that … just one wire was not working!!!
WOW… a bit shame… but this experience gave me SO RICH learnings, for the way Daniel took was so logical, simple, and organized!
He just checked the possible cause one by one, effectively using the MultiMeter (today, I think I finally understood how important MultiMeter is!), and that inspired me! as well as relieved me a lot.

Even after that, I encountered with similar strange situations in SoundSensor project (only 2 LEDs works but other 2 LEDs NOT).
I carefully checked all the details (I thought) following what Daniel did, and found that even if I change some wires, LEDs, registers, the same weird thing still happened. Also, I gradually simplified the codes until it totally changed into very very simple basic codes (not with SoundSensor), but STILL I could not figure out what was the reason.

So, finally, I started to check all the wires at my hand, and……. found that MANY of the wires at my hand were DISCONNECTED…(So, possibly, when I switched the wire, both wires were disconnected…)

It actually wasted my time, but also gave me rich and severe learnings again.
I think I am now getting used to these “physical” matters, and that also excites me a lot now!
———
Finally, as an observation, not only TV remote control etc., but also I have been observed “elevator buttons” at ITP floor during this whole week!

My assumption is that:

1) as for the floor number light’s ON/OFF, I think the elevator touches to the conductive thing for each floor (the distance between those two could be just the same as the elevator height) and that makes the circuit to turn on that floor’s number.

2) when “DOWN” button on the 4th floor (ITP) is pushed, the signal “go to the 4th to go down” to both elevators.
Based on the timeline of those (multiple) instructions and its current status, each elevator re-order the instructions and follow that each by each, converting electric energy into motion energy.
*I think I could write down the codes for that, mathematically!:)

3) from my observations, as both elevators are slow, even though the signals might be speedily conveyed to those, it often takes some time for them to get to the 4th floor with “DOWN”…
There might be more efficient codings, but I am not sure yet…
*About 30 seconds to 3 minutes waiting time

Thank you!

Sachiko Nakajima, Sep. 26th, 2018

PComp Class 2 – simple but interesting circuit –

This is the class 2 Physical Computing HW documentation. I used to be in the Ham Radio club, and learned how to make simple radios, as well as morse codes! But as I was almost totally forgetting that(!log time ago…), I was somehow at a loss first.
And I was not sure how the wires constructs a completed “circuit” on the blackboards.
However, to make things move according to the electric power which sensor converts into, and based on the coding , seems to be a big fun!

So, it took me a while to understand what’s going on and which is which.
Now, I believe I understood almost all so far…!!!
As for the blackboard, the rule is quite simple and once got, it’s like a ”labyrinth” to tell if the circuit is complete or not:)
1) holes in the same row is connected electrically if they are both in left (right) part.
2) holes in the different row, or holes between the left and the right are not connected electrically.
3) holes in the same line “+” or “-” are connected electrically.
*Usually, it seems we connect the left “+”(“-VBOLNm;) line and the right “+” (“-“) by wires and “+” connecting to Arduino voltage (e.g. 5V) and “-” connecting to Arduino ground.

And in the circuit, the voltage always is consumed all to 0V at the ground.
Here below is the quite simple (but a bit interesting?) circuit I made with my understandings and one tool “sound sensor” I accidentally bought at the store near NYU:

– Here, as a switch, I broke down one controller in the trash box at ITP, and cut the switch part. That part consists of two separate conductive parts, and once it goes into the salty water, these parts electrically connect and the circuit is made.
You can see that LED is turned on when the switch part goes into the salty water! Though here in this video, I could not show that, but actually the more I put the salt, the lighter the LED got! It was a fun!

– I used the potentiometer instead of a ordinal resistor and checked if the LED’s light power changes. In the video, it may be hard to see this change but it did, for sure.
– I used the “sound sensor” with three feet (input/ground/output?) instead of a transistor, and found that even if the circuit is incomplete, the green light there lights when it catches any sound loud enough. So, I checked the voltage difference between input and ground to find that it’s always around 4.7-4.9 V.


But, as for the voltage difference between output and ground, I found that it goes down to 3.8 when it catches the sound! (while it is 4.7-4.9 V as well with no sound).
So, it seems the sound sensor somehow changes the output voltage according to the sound volume it catches.

 

* When the circuit is complete (with the switch ON), the blue LED’s light power also changed like the green light at the sound sensor, according to the sound volume it caught.

So far, I just used the Arduino without any coding, but from next class, the code interacts with electric circuits!
I am so thrilled to go on this journey…