18 August, 2013

Changing the adress

Hello!

I'll write everything from now on, on this blog ADDRESS

The biggest reason is that blogger doesn't support very well java script for code snippets... :(

10 August, 2013

03 PIR motion sensor

Hy guys!

Today I finally finished example code for PIR and decided to do little post about it. PIR is Passive infrared sensor usually used for outdoor lights (I really can't remember any other usage except as part of the alarm system for your room :P). I wouldn't like to explain how does it work because this page made perfect job.

Something that's really important to you as programmers is kind generated signal when PIR senses a motion. First of all this is how it looks like (down here). On the left side is lens and on the right you see green board with sensor. Be careful, when you connect sensor to the Stellaris, you don't exactly connect sensor to the Stellaris, but you connect one pin from chip that is bellow that green board to the Stellaris.


Well when that is clear, now I can "comment" program I made. The task was to make simple code that will turn on on-board LED when the sensor senses the motion, else LED will be off. 


On picture above you can see how was it all connected. Little tip, always connect GND wires. When you use 2 different power supplies also connect GND together! When I was younger it made me a lot of problems (I was inexperienced). Since the PIR sensor has to have its power supply, I decided to bring it from Stellaris board. On green PIR sensor board was written +5V, OUT, GND, so it has to be connected with respect to that marks. Only OUT pin is up to you. I decided to connect mine at PA7 pin at Stellaris board (or written at the board SDA1). 

Little explanation why we have to connect power supply for PIR sensor board:
As I have mention earlier, below sensor is chip which is used for decoding signal (that sensor sends to it), every chip needs to have its own power supply so this +5V, GND is for that particular chip.

I think I mention everything that could cause problems while trying to make something with PIR sensor. Now it's time for code explanation...

Full example code you can download HERE.

As you can see on pictures bellow before little guy left LED on Stellaris board is OFF, and when little guy passes by it goes ON. 



Everything important for code is explained in comments. You'll see in there that I made few .c files for PIR and LED, it's mostly because I didn't want have troubles with shifting pins in GPIO functions, and I wanted to use my own declarations, not the ones in gpio.h file.