what’s the tea

kermit1

another practice with p5.js featuring my favorite frog, Kermit.

I knew how to make a drawing sketches with p5.js but I never knew how to make it show both the shape of what the drawing is gonna be and the trails of drawing itself. So today I’m combining the knowledge of how to insert an image file and how to use createGraphics to create a kermit stamping machine. Maybe when I have time I will add a background too so you can stamp kermit in multiple different context. click the box to start stamping your kermit.

“But that’s not my problem”

So my journey to learn p5.js as a language keeps going on. I tried to make stuffs that are on the fun end so I don’t end up getting too bored doing it. I think Kermit helps a lot.

Anyways today I went to the canzine with my school friend, Lilian, and met Emmy, my twitter buddy, for the first time. I bought a couple of cute merchandises and a really beautiful and informative zine about Hong Kong protest. And when I got home I took a long ass nap and then my roommate cooked us dinner, it was delicious.

I think things are going great. I will learn more and live more everyday.

Warm robot: heartbeat sensor

From now I’m gonna refer to my final project as Warm Robot, just a temporary name but it makes it easy to track the project’s progress.

After purchasing the pulse sensor, I tried to do a test with it with LED light as an output. It reads my heartbeat pretty well, especially when I hooked it up on my ear.

IMG_2137

(it came with an ear clip!)

I wrote the code for analog serial reader and added an LED for an output (and additional LED to test out multiple output), here’s the code:


int Threshold = 520; //the turning point when the heart beats
int LED1 = 13; //first LED, to indicate each beat
int LED2 = 5; //another output in correspondence to the first LED

void setup() {
 Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
 int Pulse = analogRead(A0); //where I plugged in my pulse sensor
 
 // print out the value you read:
 Serial.println(Pulse);

if (Pulse > Threshold){
 digitalWrite(LED1,HIGH); 
 } else {
 digitalWrite(LED1,LOW);
 }
 delay(10);

if (LED1, HIGH){
 digitalWrite(LED2,HIGH);
 delay(2);
 digitalWrite(LED2,LOW);
 delay(2); 
 digitalWrite(LED2,HIGH);
 delay(2);
 digitalWrite(LED2,LOW);
 delay(4); /* i made sure the total of delay is less than or
the same number as the LED1 delay */
 } else {
 digitalWrite(LED2,LOW);
 } 
}

 

Then I opened the serial plotter to see the graph of the value from the pulse sensor. I googled and looked around codes people have written to find a best way to count each heartbeat and so far putting a threshold seems like the simplest one that worked for me. I wonder if there’s a way to count it for each +apex and -apex? is that even possible? I think? I’ll need to consult someone for this.

IMG_2138 copy

mmmm yaA i’m alive

IMG_2138

IMG_2134

it seems to be working with LED lights, I tried piezo for a sound output but it doesn’t seem to be working.. I thought it would work if I just change it from digital to analog. Regardless, it’s a step forward!! let’s see what else I can do before class on Wednesday!