How a Bean Becomes a Fart

LPoW

By Sariel

Superfriends meets Friends

NERF STAR WARS – OFFICE JEDI

ASFoW

Today M.E. (Mysterious Explorer) send to me this.

Arduino + LCD MD216-01 Rev.A

I was back at my home for a week and I decided to bring back a few things… Among them there is an Arduino Duemilanove, some breadboards and an LCD display (MD216-01 Rev.A 16 characters 2 lines). All bougth long back at BricoGeek.

UntitledSo I decided it is a good idea to build a small project. I’m going to build a start/stop timer.

But before, do you remember my other posts about Arduino?

Father and Daugther

Raspberry Pi 001: Setup and Run first Arduino-Python project.

Hope you like them. Now for the timer. This is my list of components:

  • Arduino Duemilanove
  • LCD (taken from old equipment)
  • Button (taken from old equipment)
  • LED (taken from old equipment)
  • 2x Variable resistor (taken from old equipment)
  • Breadboard
  • Connectors
  • Piezo speaker (taken from a Christmas card)

IMAG3963

I couldn’t find any more the spreadsheet for my particular LCD, but I found a good tutorial here (The only difference is in the pins for the back-light).

1. Because I want to be able to use the Arduino and don’t destroy this project, the first step is to build a buffer in the breadboard. We connect Gnd and 5V from the Arduino to the breadboard, and Arduino digital pins from 5 to 7 to the corresponding pins in the breadboard. In this way we can remove the Arduino and know exactly which pins we need to connect again.

IMAG3964[1]

2. Connect LCD in the left hand side as shown. Pins will go from 1 to 16 in this model.

IMAG3965[1]

To understand what pins do, we have this nice video.

3. Connect pins!

LCD  –> Arduino

1 — Gnd

2 — +5V

3 — Middle pot of a variable resistor between +5V and Gnd

4 — 7

5 — Gnd

6 — 8

11 — 9

12 — 10

13 — 11

14 — 12

15 — Gnd

16 — Middle pot of a variable resistor between +5V and Gnd

The variable resistors will control the back ligth and the contrast. Once it is set you can read their value and replace them with standard resistors.

Now connect the piezo to Gnd and Pin 6 of the Arduino. Connect the LED to Gnd and Pin 5.

For the button, connect one side to Gnd  and the other side will be connected to a resistor that goes to +5V and a capacitor that goes to Pin 4. The final result is something as messy as this:

 IMAG3966[1]

4. Now your LCD screen is connected to the Arduino, time to check it. To do that load an example File>Examples>LiquidCrystal>HelloWorld

Before running this example you need to define which are the pins. In our case it has to be:

LiquidCrystal lcd(7,8,9,10,11,12);

Now you can compile and upload the code:

IMAG3967[1]

5. Let’s now modify this to show a proper clock counter and make Arduino to read the button to reset the counter. We start with the code for the HelloWorld and tweak it a little bit:

 

#include "pitches.h" //For playing a note with the piezo
#include <LiquidCrystal.h> //Libraries for the LCD

LiquidCrystal lcd(7,8,9,10,11,12);  //Defiying the pins in the LCD

int notes[] = {
  NOTE_A4, NOTE_B4,NOTE_C3 }; //3 notes

const int buttonPin = 4;     // the number of the pushbutton pin
const int ledPin =  5;      // the number of the LED pin
const int piezoPin =  6;      // the number of the piezo pin

int buttonState = 0;         // variable for reading the pushbutton status
int counter = 0;
int hours = 0;
int minutes = 0;
int seconds = 0;

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);    
  // initialize the piezo pin as an output:
  pinMode(piezoPin, OUTPUT); 
  // Writte in the LCD symbols that will not change
  lcd.print("Run!!!");  
  lcd.setCursor(2, 1);  
  lcd.print(":");
  lcd.setCursor(5, 1);  
  lcd.print(":");
  lcd.setCursor(8, 1);
  lcd.print(".");  
}

void loop(){  
  //Now while the button is unpressed the counter will tick
  while (digitalRead(buttonPin)== HIGH){
    digitalWrite(ledPin, HIGH);  
    noTone(piezoPin);
    delay(100); //wait for 100 ms
    counter = counter +100;
    //This is for setting the counters into the next multiple
    if (counter>= 1000){
      seconds=seconds++;
      counter=0;
    }
    else{}
    if (seconds>= 60){
      minutes=minutes++;
      seconds=0;  
    }
    else{}
    if (minutes>= 60){
      hours=hours++;
      minutes=0;  
    }
    else{}
    //Now this code is for writting the time
    //We want to have zeros before numbers
    if(hours>9){
      lcd.setCursor(0, 1);
    }
    else{
      lcd.setCursor(0, 1);
      lcd.print(0);
      lcd.setCursor(1, 1);
    }
    // print the number of hours since reset:
    lcd.print(hours);   
    if(minutes>9){
      lcd.setCursor(3, 1);
    }
    else{
      lcd.setCursor(3, 1);
      lcd.print(0);
      lcd.setCursor(4, 1);
    }
    // print the number of minutes since reset:
    lcd.print(minutes);  
    if(seconds>9){
      lcd.setCursor(6, 1);
    }
    else{
      lcd.setCursor(6, 1);
      lcd.print(0);
      lcd.setCursor(7, 1);
    }  
    // print the number of seconds since reset:
    lcd.print(seconds);
    if(counter/100>9){
      lcd.setCursor(9, 1);
    }
    else{
      lcd.setCursor(9, 1);
      lcd.print(0);
      lcd.setCursor(10, 1);
    }
    // print the number of seconds since reset:
    lcd.print(counter/10);
  }
  //When we press the button the LED will be off and the counter reset
  // turn LED off:
  digitalWrite(ledPin, LOW); 
  tone(piezoPin, notes[1],20);
  counter =0;
  seconds =0;
  minutes=0;
  hours=0;
}

 

NOTE: Sometimes the command

 #include "pitches.h"

doesn’t work properly and you need to load and compile the example File>Examples>Digital>toneMelody

 

and voilà!!!!

IMAG3969[1]

Hope you like it.

.

.

.

.

.

.

.

.

.

.

.

Ok ok, one extra, look at this SNES-like controller they sell, isn’t it awesome?

Untitle2d

 

LPoW

1304607906m_SPLASH

By Sariel

Modular Marble Machine!

ASFoW

Today M.E. (Mysterious Explorer) send to me this.

Automatic Particle Sizing Using IMAGEJ

I have been on holidays for a while so it’s time to go back to work. Today I’m going to show an easy way of counting/measuring particles using a free software. The image analysis software is called ImageJ.

imagej-logo

ImageJ can be downloaded and used for free. The first thing that appears once installed is the toolbox.

toolbox

To load your image just File>Open. In my case, I’m going to use an SEM image where a few nanoparticles where split. (Thanks Nimkahl for the image). If you want to practice with it, just right click and download it.

MNP

Once the image is loaded into the program, the first thing is to get the scale of the image. For doing that, simply focus on the scale bar Ctr + Up Arrow. Then use the rectangular bottom to drag a rectangle that fits into the scale bar. Now Analyze>Measure to show the width and height of the rectangle. In this way we will know the relation between size and pixels. In our case 10 micronmeters is the same as 237 pixels.

scale

Now Analyze>Set Scale and use the numbers we got. 

scaleadjust

Hit Ok and the scale will be set. To make sure it is correct, if you try now to measure again the rectangle it will have 10 micrometers in length.

The next step now is to turn the image into grayscale (it is almost now but it will make your life easier). Simply Image>Type>8-bit. And now using the threshold you might be able to pick only the nanoparticles. Image>Adjust>Threshold. Make sure the nanoparticles look like red dots.

threshold

Once you apply the threshold it should look similar to this.

spots

Now it’s the moment to do nanoparticle counting. Because this image has edges it will not work very well, so I will limit the detection to a particular area. Analyze>Analyze Particles. In the menu that appears you can select many options. Since I know the nanoparticles are around 1 micrometer^2 in area I’m going to limit the Size. Circularity doesn’t have too much effect here because I limit the area where to look for nanoparticles. Include holes is very important because usually nanoparticles appear as a black ring.

area

When you run this analysis the output looks like this. It will show what was identified as nanoparticles, the summary of the results and also each individual nanoparticle.

dots

According to this the area of the nanoparticles is around 0.982 micrometers^2, good result. And it identify 27 nanoparticles. These results can now be exported into excel files, just in each window File>Save As and save the excel table, or can be plot. In the Results table Results>Distribution and select to use the round. It will appear something like this indicating the most of the nanoparticles are close to be round with a few of them differing quite a lot from round shape.

distribution

Hope you find it interesting.

Follow

Get every new post delivered to your Inbox.

Join 498 other followers

%d bloggers like this: