Arduino Home

An Open-Source platform to create digital devices and interactive objects that sense and control physical devices.

Arduino Tutorials
Arduino Projects

 

Arduino Starter Kit Competition INDEX:

 

Element14's Arduino Starter Kit Competition

Element14's Arduino Starter Kit Competition - Part 1

Element14's Arduino Starter Kit Competition - Part 2

Element14's Arduino Starter Kit Competition - Part 3

Element14's Arduino Starter Kit Competition - Part 4

Element14's Arduino Starter Kit Competition - Part 5 (motor fun)

Element14's Arduino Starter Kit Competition - Part 6

Element14's Arduino Starter Kit Competition - Part 7

Element14's Arduino Starter Kit Competition - Final Part and Conclusions

 

Project Book - 03 Love-O-Meter

Ah, just what I've always needed, a project to measure whether I'm a 'hot guy' ( the Uno gives it's verdict on me at the end of this blog).

 

A novice would have to be a little careful here as I noticed some BC547 transistors in the component pack using the same package as the temperature sensor I need for this project. Before getting to code the Uno the book talks about a cardboard cutout (in a similar theme to the Spaceship Interface) - but unfortunately it the picture they show wouldn't work as the temperature sensor is at the top of the board and the lips they want over the temperature sensor are at the bottom of their overlay. Again, this might confuse some beginners or stop their project working. I moved by board layout to place the temperature sensor at the bottom. So we've got (1) heart for hot, (2) thumbs up for middle temperature and (3) a fish for the coldest temperatures.

 

 

photo_2017-08-18_22-08-09.jpg

With the sketch written I compiled it and got my first error message - I had omitted some closing speech-marks which was easy to spot. After re-compiling I uploaded the sketch and opened the Serial Monitor and noticed another error of mine. I had quoted "sensorVal" rather than providing it as a variable and so the Serial Monitor was echoing that string. A quick change of code and I produced this output on the Serial Monitor:

Project_03_SerialMonitor.jpg

That was with me holding the temperature sensor in my fingers and getting to illuminate the 'Good' LED....I'm happy with that !

 

The Serial Monitor on the Arduino Uno is great. It looks like a really simple way of interfacing to the user, adding outputs, adding debug info, version info etc. I only needed to add one line of code to my sketch to activate it as well.

 

const int sensorPin = A0;

const float baselineTemp = 23.0;          // change accordingly to your background temperature

 

void setup() {

  // put your setup code here, to run once:

  Serial.begin(9600);

 

  for (int pinNumber=2; pinNumber<5; pinNumber++){

      pinMode(pinNumber,OUTPUT);

      digitalWrite(pinNumber,LOW);   

  }

}

 

void loop() {

  // put your main code here, to run repeatedly:

  int sensorVal = analogRead(sensorPin);

 

  Serial.print("Sensor Value: ");

  Serial.print(sensorVal);

 

  //convert the ADC value to it's voltage representation

  float voltage = (sensorVal/1024.0)*5.0;

 

  Serial.print(", Voltage: ");

  Serial.print(voltage);

 

  Serial.print(", Degrees C: ");

  float temperature = (voltage - 0.5)*100;

  Serial.println(temperature);

 

  if (temperature < baselineTemp){

    digitalWrite(2,LOW);

    digitalWrite(3,LOW);

    digitalWrite(4,LOW);   

  }

  else if (temperature >= baselineTemp+2 && temperature < baselineTemp +4){

    digitalWrite(2,HIGH);

    digitalWrite(3,LOW);

    digitalWrite(4,LOW);    

  }

  else if (temperature >= baselineTemp+4 && temperature < baselineTemp +6){

    digitalWrite(2,HIGH);

    digitalWrite(3,HIGH);

    digitalWrite(4,LOW);    

  } 

  else if (temperature >= baselineTemp+6){

    digitalWrite(2,HIGH);

    digitalWrite(3,HIGH);

    digitalWrite(4,HIGH);    

  }

  delay(1);

}

 

Summary of Project-03

Although the project book is great, nice quality paper/print and well laid out, I am spotting some errors that Arduino could easily amend, especially if the book was online which doesn't seem to be the case; many of the www links appear to be invalid or have simply moved. However, I don't think this detracts from the learning value of the kit but perhaps something novices should consider - e.g. if it doesn't work or make sense then perhaps the book is wrong....use Google or a forum search to make sure.

 

[Next Project: Colour Mixing Lamp]