Thursday, September 29, 2011

LM335 + Arduino temperature sensor

Few weeks ago I’ve bought a LCD 16x2 display. I wanted to create a room temperature sensor. 


I’ve been using pocket arduino and there’s been some issues with resetting. I had to burn bootloader once again, so it took me longer to make this post. Also I’ve picked LM35 for this project (cool but expensive), but I’ve burned it. So I was forced to go with LM335 (not that cool but cheap). You can download code and watch video below. 

Code : 

#include <LiquidCrystal.h>
float raw;
float temperature;
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
byte degree[8] = 
{
B01100,
B10010,
B10010,
B01100,
B00000,
B00000,
B00000,
B00000
};

void setup()
{
  lcd.begin(16, 2);
  lcd.print("Temperature :");
  lcd.createChar(0, degree); 
  lcd.setCursor(7,1);
  lcd.write(0);
  lcd.setCursor(8,1);
  lcd.print("C"); 
}

void loop()
{
 raw = analogRead(0);
 temperature = ((raw*480.0/1024.0)-273); 
 lcd.setCursor(1,1);
 lcd.print(temperature);
 delay(500);
}



Sunday, September 18, 2011

Sound/noise sensor for Arduino

For quite some time I’ve been looking for some sort of sound or noise sensor. I had some electrolytic microphones lying around, so the only problem was amplifier. 



Well you can choose either some IC or some simple transistor ones. At first I’ve tried LM386, but I found out that it’s not very good. The reason is that this IC is not meant to be used as a pre-amp. I’ve decided to use this single transistor setup with 2N3904. I’ve also bought big white board and drawn the circuit. It’s really cheap sound/noise detecting sensor and it work’s good.

Arduino code :

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

void loop()
{
 int minimum = 1024;
 int maximum = 0;
 for(int i=0;i<1000;i++)
 {
  int value = analogRead(A0); 
  minimum = min(minimum, value);
  maximum = max(maximum, value);
 }
 Serial.print("noise=");
 Serial.print(maximum-minimum);
 Serial.println(); 
}



Saturday, September 10, 2011

Pocket Arduino

Well, I have to admit that I’m little bit obsessed with Arduino clones. I always wanted to create my own pocket portable Arduino. 


I thought that Altiods tin would be perfect housing for such a project. I also had one ATmega328 laying around. There were few abilities I wanted my pocket Arduino to have. Since I wanted my Arduino to be pocket or let say portable there should be some sort of power source inside. I quickly chose 9V battery for that purpose, because arduino itself doesn’t have that big power consumption and there are still pins that I can use for other voltage input. Then I needed somehow to upload code to Arduino, so I needed some way to communicate between Arduino and PC. I chose one of that small USB to TTL converters. Keeping in mind that this Arduino has to be portable I’ve desoldered female USB type D connector that was there and replaced it with male USB connector. With this option I don’t need any USB cable, (maybe USB extender if you don’t have laptop) I can just plug the whole Altoids tin inside my PC. Another thing I wanted was small breadboard, because that’s the thing that makes Arduino portable. There were more things I wanted to have there, but even with these, it was really hard to close the tin after I've placed everything inside. But after all I’m really satisfied with the success. Arduino is fully operational, portable and still looks like mints case.