A door keeper with a kinect and a attiny2313 the entire solution given here

Sep 1, 2014 at 8:32 PM
Edited Sep 17, 2014 at 6:12 PM
it been a long time a worked on this project... but i didn't worked on it all the time... this is my first project i knew nothing in programmation when i have started this...and i can finish it by myself and i don't want to loose everything so i let it here to see if it interess someone:

Under is the schema it work with an attiny23 and MAX3232CPE with a 7.3728 and it communicate with the computer using the serial port the attiny2313 is connected to 4 button wich are used for the bell ring :

Image

Here is the programme written on C thanks to internet and people who have made site:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

 #define LED PB1 // Define ext led pin on PB1 

void InitializeSerial( void );
void serialTx( unsigned char );
void serialTxString(char *);
char serialRx( void );
void init_timer(void);
void stop_timer(void);
void rothoraire(void);
void antihoraire(void);
void stopmotor(void);

volatile char ReceivedByte ='\0';
volatile char TransmitByte='\0';
int i = 0;


 int main (void)  
 {  
    
    
    DDRB = 0x07;
    PORTB = 0x07;
    InitializeSerial();
    UCSRB |= (1 << RXCIE);
    
    
    sei(); // Enable the Global Interrupt Enable flag so that interrupts can be processed
      
    _delay_ms(10000);
     serialTxString("mok");
     
     
    
      for(;;)
    {
                
    
        switch (ReceivedByte)
        {
        case 'r' :
        init_timer();
        ReceivedByte = '\0';
        break;
        
        case 'v' :
        stop_timer();
        ReceivedByte = '\0';
        break;
        
        case 'a' :
        rothoraire();
        ReceivedByte = '\0';
        break;
        
        case 'z' :
        antihoraire();
        ReceivedByte = '\0';
        break;
        
        case 's' :
        stopmotor();
        ReceivedByte= '\0';
        break;
        
                                
        default:
        break;
        
        }       
        
        /*
        i=0;
        
        
        if (ReceivedByte=='b')
            {
            serialTx('5');
            _delay_ms(2500); 
            }
         if(ReceivedByte== 0xff)
            {
            
            ReceivedByte= 'g';
            }
        else
            serialTx(ReceivedByte);
            */
        
    }
} 
     
ISR(USART_RX_vect)
    {
                ReceivedByte = UDR; // Fetch the received byte value into the variable "ByteReceived"
                _delay_ms(2500);
    }

void InitializeSerial(void)
    {
                UBRRH = 47>>8;
                UBRRL = 47;//Set baud rate 9600
                //UBRRL = 191;//Set baud rate 2400
                UCSRB = (1 << RXEN) | (1 << TXEN);
                //UCSRC = (1 << UCSZ1) | (1 << UCSZ0);//8data 1stop bit
                UCSRC = (1<<USBS)|(3<<UCSZ0);// Set frame format: 8data, 2stop bit 
    }

void serialTx( unsigned char data )
    {
                while ( !( UCSRA & (1<<UDRE)) ){}//Wait to see if buffer is empty
                UDR = data;//Sends data through buffer
    }

char serialRx()
    {
                char received = UDR;               
                return received;//Get and return received data
    }

void serialTxString(char * str)
    {
                int i=0;
                while(str[i] != '\0') 
                    {
                    serialTx(str[i++]);
                    }
                PORTB ^= 0xFF;
                _delay_ms(1000);
    }   

void init_timer()
    {
PORTB = 0b11111011;
//DDRB |= (1<<PB2);
//DDRB = 0x04;
/* Set Fast PWM mode. */
TCCR0A |= (1<<WGM00) | (1<<WGM01);

/* Clear 0C0A on compare. */
TCCR0A |= (1<<COM0A1);

/* Start timer, no prescaling. */
TCCR0B |= (1<<CS00);

/* Duty cycle 100% */
OCR0A =60;

serialTxString("ledon");
    }
        
void stop_timer()
    {
    //OCR0A = 0;
    TCCR0A = 0b00000000;//~(1<<WGM00) | ~(1<<WGM01);
    TCCR0B = 0b00000000; //~(1<<CS00);
    PORTB |= 0b11111111;
    serialTxString("ledof");
    }

void rothoraire()//pb0 jaune
    {
        PORTB = 0b11111111;
        PORTB = 0b11111110;
        
        serialTxString("rotho");
    }
    
void antihoraire() //pb1 rouge
    {
      PORTB = 0b11111111;       
      PORTB = 0b11111101;
      serialTxString("antiho");
    }
    
void stopmotor()
    {
    PORTB |= 0b11111111;
    serialTxString("motstop");
    }




Ok that not really a programm for the button of the door keeper i can 't find it anymore put this one can make run a motor with a H brigde and bright a Led with PWM (power with modulation)
if you can understand this you guess that modify this programme to juste check if a button is pressed will not be a problem.

here is the programme working with the kinect running on a computer next to the gate
(the server).
It use lot of library, naudio, voice synthesize, etc...
Sep 1, 2014 at 8:42 PM
Edited Sep 17, 2014 at 6:14 PM
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Kinect;
using Coding4Fun.Kinect.KinectService.Common;
using Coding4Fun.Kinect.KinectService.Listeners;
using System.Media;
using System.IO;
using System.Threading;


namespace portail_3._0
{
/// <summary>
/// Logique d'interaction pour MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
    KinectSensor mykynect;
    ColorListener colorListener = null;
   // AudioListener audioListener = null;
    SerialCom monport;
    LanCom lanCom;




    public MainWindow()
    {
        InitializeComponent();


    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {





        foreach (var potentialSensor in KinectSensor.KinectSensors)
        {
            if (potentialSensor.Status == KinectStatus.Connected)
            {
                this.mykynect = potentialSensor;
                break;
            }
        }

        if (null != this.mykynect)
        {
            try
            {
                mykynect.ColorStream.Enable(Microsoft.Kinect.ColorImageFormat.RgbResolution640x480Fps30);
                // Start the sensor!
                this.mykynect.Start();
               LaVoix.VirginieParle("Démarrage des systèmes...  Le kaïnect fonctionne... Je peux donc voir et entendre... ");

            }
            catch (IOException)
            {
                // Some other application is streaming from the same Kinect sensor
                this.mykynect = null;
            }
        }
        if (null == this.mykynect)
        {
            LaVoix.VirginieParle("Démarrage des systèmes...  Impossible de détecter un kaïnect...  Sans celui ci je suis aveugle et sourde:  Mon système a besoin d'être vérifiez.  ");
            return;
        }




        colorListener = new ColorListener(mykynect, 4530,ImageFormat.Jpeg);
        //audioListener = new AudioListener(mykynect, 4533);
        colorListener.Start();
        //audioListener.Start();
        lanCom = new LanCom();
        monport = new SerialCom();


    }

    private void Window_Closed(object sender, EventArgs e)
    {
        if (monport !=null ) monport.SerialPortStop();
        if (colorListener!=null) colorListener.Stop();
        //audioListener.Stop();
        if (mykynect!=null) mykynect.Stop();


    }




}
}
Sep 1, 2014 at 8:57 PM
Edited Sep 17, 2014 at 6:15 PM
voila
i made a new one