ERU, Fall 2014 – Stephanie and Julia’s Post

IMG_1227

IMG_1226

 


Hey friends,

Julia and Steph, here. The two of us participated in a one-unit experiential learning course in electronics with Dale, Jay, Matt, and John. Neither of us came into the course with any kind of background in electronics or coding, so we definitely finished the module knowing a lot more than when we started. In order to program Arduino, over the course of the few days we were introduced to coding. Being so inspired by this new language, we felt the best way to describe our experiences would be to put them in code form. We hope it makes sense.

Disclaimer: This may be hard to wire on a starter Arduino kit.

//We started with nothing. No knowledge. No equipment. Jay, Matt, Dale and John provided everything. We just brought our sunny attitudes and the will to take on a challenge.

#include <arduino.starter.kit>

#define ARTSCI_3IE3

#include Stephanie and Julia + iSci and ArtSci classmates

//Let’s actually try to make things do things.

void setup() {

// initialize digital pin 13 as an output.

pinMode(13, OUTPUT);

}

//Let there be light!

// The loop function runs over and over again forever (seriously, forever).

void loop() {

digitalWrite(13, HIGH);

delay(5000);

digitalWrite(13, LOW);

delay(1000);

}

//This is where our light started to blink! So cool!  All we needed were these few lines of code! I bet you’re curious to know what else the Arduino can do 🙂

//We messed with a few wires and new attachments (e.g., a speaker!). We read some diagrams.

//Music was one of our strengths, so the challenge of coding a song was right up our alley.

int melody[] = {EVERYTHING IS COOL WHEN YOU’RE PART OF A TEAM!

NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_G4, 0, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_GS4, NOTE_G4, NOTE_F4, NOTE_DS4, NOTE_F4, NOTE_G4, NOTE_F4}};

// Ahh! Yes! We figured out how to make quarter notes (by the third day)! Not this song, but Here Comes the Sun was totally rhythmically accurate! We have never been more proud of ourselves!!!

// note durations: 4 = quarter note, 8 = eighth note, etc.:

int noteDurations[] = {16, 8, 8, 9, 16, 16, 16};

// Our first light was just one colour, but by day two we had graduated to multi-colour LEDs. A large part of the challenge here was to wire it, but we were ready. By day three, we had our lights hooked up to a sensor so that it functioned like a night light: DARK = LIGHT ON. BRIGHT = LIGHT OFF. It was like our little Arduino had a mind of its own. Awwww!

int redPin = 11;

int greenPin = 10;

int bluePin = 9;

int Temp = 0;

int R = 0;

int B = 0;

// So… fun fact! Arduino also doubles as a thermostat! Sadly, its default is Fahrenheit. 🙁 But, not very much code later, it was telling us the temperature in Celsius. We Canadianized it. For our final device, we had the thermostat hooked up to Arduino’s speaker so that it played Here Comes the Sun only when the temperature was above 27 degrees.

double Thermistor(int RawADC) {

double Temp;

Temp = log(10000.0*((1024.0/RawADC-1)));

Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );

Temp = Temp – 273.15;

return Temp;

}

// How did we do it? We learned to make if/then statements! So logical. Here is what we used to make the song play when the temp. hit 27 degrees.

if(sensorValue >=27){

// iterate over the notes of the melody:

for (int thisNote = 0; thisNote < 37; thisNote++) {

}

// This is where things got even more interesting. We made a connection between colour and temperature, so that when it got cold, our light would go blue, and when it got warm, the light would go red. Magic!

sensorValue = Thermistor(analogRead(0));

R = map(sensorValue, 23, 29, 0, 255);

B = map(sensorValue, 29, 23, 0, 255);

setColor(R, 0, B);

// Of course, it’s important to be able to read what you’re doing (especially when something doesn’t seem to be working, which tends to happen).

// print the results to the serial monitor:

Serial.print(“sensor = ” );

Serial.print(sensorValue);

Serial.print(“\t output = “);

Serial.println(outputValue);

}

It may not be the most coherent few lines of code you’ve ever seen, but we wanted to show some glimpses into what it was like to be part of this class. In case it was unclear (and it definitely was), our final device served as a musical night-light with bonus features. It had a light that turned red when it got warm and blue when it got cold.  With its temperature sensor, it also set off a musical warning when it got to a certain temperature. A second light was hooked up to a photoreceptor, so that the light turned on when the sensor was covered and off when we let light shine upon it. Finally, as our guidelines required, we had a fun bonus feature. Using the infamously tricky button, we set up our Arduino to flash a series of rainbow lights.

Overall, a very rewarding, not to mention empowering experience. We came in with nothing, and we left with some sense of how all of the electronics around us work. We also gained the tools we would need to start programming our own electronics, and since we get to keep our Arduino kits we, hope it doesn’t end here.

Thanks to Dale, Jay, Matt and John for a wonderful experience! Hope to see you around again soon!

To all of you students reading this post: great course! We would highly recommend it 🙂

 

Love,

Stephanie Drouin and Julia Redmond

Posted in Blog, Electronics for the Rest of Us!

Leave a Reply

Your email address will not be published. Required fields are marked *

*