Project 1: Spinning Lily

For my first physical computing project I wanted to use the temperature sensor as this was something I was interested in working with. To start with I got the temperature sensor working then I added a led so that I could start to put the temperature sensor to use. I played around with the temperature coding so that I could get the led to light after a certain temperature was reached, for this I used the temperature cut off command e.g.

if(temperature>temperature_cutoff) {

digitalWrite(led, HIGH);

delay(1000);

digitalWrite(led, LOW);

delay(250); }

Using the delay command I could decide how long there was between each led blink e.g. delay(500).

This is how the led comes on after the temperature has been reached.

reading = analogRead(sensorPin); //get reading
voltage = (reading * 5.0) / 1024.0; //convert to voltage
temperatureC = (voltage – 0.5) * 100 ; //convert to temp in degrees C
temperatureF = temperatureC * 9/5 + 32;

if(temperatureF > temperature_cutoff)
{
digitalWrite(led, HIGH); // turn the LED on if the temp is over 60
}

research

Blink with Resistor

http://www.flutterwireless.com/tut/002.html

Thermistor

Rotary Motor

https://learn.adafruit.com/downloads/pdf/adafruit-arduino-lesson-10-making-sounds.pdf

http://www.maplin.co.uk/p/wire-ended-piezo-buzzer-cr34m

 https://www.youtube.com/watch?v=4QtxagEy7K0

Temperature sensor code

int temperaturePin = 0;

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

void loop() // run over and over again
{
float temperature = getVoltage(temperaturePin); //getting the voltage reading from the tem
//perature sensor
temperature = (temperature – .5) * 100; //converting from 10 mv per degree wit 500
// mV offset
//to degrees ((volatge – 500mV) times 100)
Serial.println(temperature); //printing the result
delay(1000); //waiting a second
}

e(int pin){
return (analogRead(pin) * .004882814); //converting from a 0 to 1023 digital range
// to 0 to 5 volts (each 1 reading equals ~ 5 milliv
//olts
}

IMAG0811

Thermistor

Motor

Next I needed to add something to make this project a bit more interesting so I decided to add a motor that would constantly spin as soon as the temperature cut off temp was reached this was a bit more difficult than the led to setup and code but from looking at existing codes and schematic diagrams I was able to work out how to get mine to work with what I wanted it to do.

The ‘else’ command was a key command in my code as this allowed me to use the same ‘if’ statement but do the opposite to the previous commands within the same ‘if’ statement.
int motorPin = 9; // define the pin the motor is connected to

// (if you use pin 9,10,11 or 3you can also control speed)

void setup()
{
pinMode(motorPin, OUTPUT);
}
void loop() // run over and over again
{

CIRC00-sheet-SPAR

Rotary Motor

IMAG0816

Another component I wanted to add to my project was a buzzer that would sound when the max temperature had been reached. I could have the buzzer on constant but could not incorporate it into the same code where it would come on with the led and motor. It will be something I look into more to find a way to get this to work.

http://www.maplin.co.uk/p/wire-ended-piezo-buzzer-cr34m

https://learn.adafruit.com/downloads/pdf/adafruit-arduino-lesson-10-making-sounds.pdf

The final code

int speakerPin = 12;

int numTones = 10;
int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440};
// mid C C# D D# E F F# G G# A
void setup()
{
for (int i = 0; i < numTones; i++)
{
tone(speakerPin, tones[i]);
delay(500);
}
noTone(speakerPin);
}

model working.

IMAG0821

First model

IMAG0823

Final circuit layout

first project complete

My final product

My project is a temperature sensing product that can be placed in the garden and will activate when the temperature outside increases, useful for gardeners, pond owners, or just for someone who wants to see it from inside their home to see that it is a warm day. Fairly simple project but really good to learn how to bring everything together.

IMAG0824

This is my first time using Arduino and coding but from taking on this project I have learnt so much from setting up the breadboard to basic coding to how the components work and all the different types of components.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s