Showing posts with label peter mbari. Show all posts
Showing posts with label peter mbari. Show all posts

Tuesday, 1 April 2014

making infrared intruder counter / alarm


Introduction

This is a gadget for counting the number of times an infrared beam of light is interrupted. It is arduino based and implemented with an atmega328 chip on a veroboard. This is an easy project and may take a day to put together.

The counter working

Parts required

  • 220 ohms resistors
  • 10k resistors 
  • 4 digit 7 segment display
  • atmega328p/ arduino uno
  • infrared photo transistor
  • infrared diode
  • 7805 voltage regulator
  • power source: 7.5Vdc to 15Vdc
  • buzzer

Connecting it together

I use the pin mapping of the atmega328p from the arduino site and is also shown below. To protect the microcontroller pins from being destroyed by large currents that may flow, add 220 ohms resistors on the common cathodes or anodes of your display. 

For connecting the 4 digit  7 segment display use the assignment shown in the picture below. Just in case you have the same display I had, otherwise find the display pin assignment in the datasheet.



Connect the 4digit 7-segment display using pin assignement in the code and load the code to the MCU using a programmer. For me I use UsbTinyISP.

Code


/*Written by Dean Reading, 2012.  deanreading@hotmail.com
/Edited by Peter Mbari to Count number of Intruders using Infrared
 

 */

#include "SevSeg.h"

//Create an instance of the object.
SevSeg sevseg;

int sPin=12;
int buzzer=13;
int people=0;
//Create global variables
unsigned long timer;
int CentSec=0;

void setup() {
  //I am using a common anode display, with the digit pins connected
  //from 0-3 and the segment pins connected from 4-11
  sevseg.Begin(1,0,1,2,3,4,5,6,7,8,9,10,11);
  //Set the desired brightness (0 to 100);
  sevseg.Brightness(50);
  
  pinMode(sPin, INPUT);// Setup the Infared sensor pin as input
  
  pinMode(buzzer, OUTPUT);// Set Buzzer pin as output
  timer=millis();
}

void loop() {
  //Produce an output on the display
  sevseg.PrintOutput();
  
 if(digitalRead(sPin)==LOW)
 {
   people++;
  while(digitalRead(sPin)==LOW)sevseg.PrintOutput();
  digitalWrite(13,HIGH);  
  delay(500);
  digitalWrite(13, LOW);
 }
 
  
    //Update the number to be displayed, with a decimal
    //place in the correct position.
    sevseg.NewNum(people,(byte) 0);
  
}


Finaly after the board is assembled and working you get a nice display like the one shown in the video below.




Happy making








Sunday, 16 June 2013

Adventure in Lake Victoria

I have been to the lake many times before but the experience I had this time supersedes all others. This time I made an effort to document the adventure with pictures. This was a rare case when fieldwork turned out to be more fun than I had ever had before. From the pictures you have to agree that it was really fun.

For those of you wondering where this happened, it was in Mfangano Island, Rusinga Island, and Mbita in Kenya.


Posing inside an old broken boat at Lunanda Rombo

Batteries for the Ekialo Kiona Solar install

Posing with a wind turbine blade after repairing the wind turbine

Beautiful sunset at mfangano's Soklo mountain

beautiful sunset on Mfangano

great view of the lake from atop the hill with maize growing on the hill side


Sunrise at Sena, Beautiful indeed


the fish we caught

fishing at the lake early in the morning