Arduino: LCD + PIR (mugimenduen sensorie)

Denpora asko idatzi barik eta geisorik nauela aprobetza eta mugimentuen sensorie iminjot arduinogaz martxan:

Erreza, sensoriek mobimientue notaten daueniko ba LCD-n idaztentu.

Argazkidxe:
https://img.imgur.com/eZ13N68.jpg

Zirkuituen mapie:
https://img.imgur.com/cAwkAcG.png

Kodigue:

//DFRobot.com
//DFRobot.com
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include  // 
#include  // 
LiquidCrystal_I2C lcd(0x27, 516,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

// PIR Sensorie 2 PIN digitalien
int motion_1 = 2;
void setup()
{
	lcd.init();
	lcd.backlight();
	// PIR Sensorie
	pinMode (motion_1, INPUT);
}

void loop()
{
	// LCD resetie
	lcd.clear();
	lcd.setCursor(0, 0);
	// PIR Sensorie leidu
	int sensor_1 = digitalRead(motion_1);
	if (sensor_1 == HIGH)
		lcd.print("Mobidu");
	else
		lcd.print("Geldik");
	// 100 milisegundoko deskantsue :D
	delay(100);
}

Bididxue martxan:

Github-en kodigue: https://github.com/ZiTAL/arduino/blob/master/LCD_I2C_PIR/LCD_I2C_PIR.ino

Github-en arduino proiekto osue: https://github.com/ZiTAL/arduino/

avconv/ffmpeg: Abesti bategaz eta irudi bategaz bididxo bat sortu

Ein bidoten bakotzien beti nabil topaten interneten ta gero eztot apunteten ta han otenai 5 ordu, ba hamen imiñi ta listo ostia.

Abesti bategaz eta irudi bategaz bididxo bat sortuteko avconv erabilku:
abestidxe: input.mp3 320k
irudidxe: logo.png 1920×1080

avconv -i input.mp3 -loop 1 -f image2 -i logo.png -r 30 -s 1920x1080 -ab 320k -ar 44100 -ac 2 -t 00:10:00.000 output.webm

-i input.mp3: Abestidxen fitxategidxe.
-loop 1: Irudidxe bardine okingule bueltaka.
-f image2: irudidxe dala esateko.
-i logo.png: Irudidxen fitxategidxe.
-r 30: 30 frame segunduko, logikuena 1 okitzie ezango lekide baie eztabil ondo segun ze formatotan.
-s 1920×1080: Irudidxen tamañuen beste, hartun konpatiblie dan tamañoren bat.
-ab 320k: Abestidxen kalidade mailie.
-ar 44100: Abestidxen frekuentzidxe.
-ac 2: Stereo.
-t 00:10:00.000: 10 minutu-ko abestidxe badan.
output.webm Non gordekun

Arduino: 4×4 Matrizie

http://i01.i.aliimg.com/wsphoto/v3/570594709_1/Wholesale-10pcs-lot-4x4-Matrix-Keyboard-Keypad-Use-Key-PIC-AVR-font-b-Stamp-b-font.jpg

Hau matrizie erosi dot arduinori konektateko, erosi gurebazuien kontuz ze pin barik dator eta solda inbidiez pinek.

Hamen daku beronen katxarruen instrukziñuek:
http://www.cytron.com.my/usr_attachment/s%20Manual.pdf

Bueno ba hamen daku zirkuituen irudidxe:
https://img.imgur.com/UepaWmE.png

Puntetan dauzen pin bidxek ez dauie balijo eta X bategaz marka dotez.

Eta hamen argazkidxe:
https://img.imgur.com/WiuoEEb.jpg

Goiko irudidxetan ikusten dun moduen zutabiek resistentzi batzuk biher dauiez: 10K omh

https://ultimachine.com/sites/default/files/imagecache/product_full/Resistor_1_1.jpg

Oin Lerro eta zutabiekaz dau zatitxute, lehenengo 4 pinek zutabiek diez eta hurrengo 4 pinek lerruek, oin kodiguen ikusku hobeto:

/*  Keypadtest.pde
 *
 *  Demonstrate the simplest use of the  keypad library.
 *
 *  The first step is to connect your keypad to the
 *  Arduino  using the pin numbers listed below in
 *  rowPins[] and colPins[]. If you want to use different
 *  pins then  you  can  change  the  numbers below to
 *  match your setup.
 *
 */
#include 

const byte ROWS = 4; // Four rows
const byte COLS = 4; // Four columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = { 2, 3, 4, 5};
// Connect keypad COL0, COL1, COL2 and COL3 to these Arduino pins.
byte rowPins[ROWS] = { 6, 7, 8, 9};
  // Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

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

void loop()
{
  char key = kpd.getKey();
  
  if(key)  // Check for a valid key.
  {
    Serial.print(key);
  }
}

Ikusten dun moduen:

// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte colPins[COLS] = { 2, 3, 4, 5};
// Connect keypad COL0, COL1, COL2 and COL3 to these Arduino pins.
byte rowPins[ROWS] = { 6, 7, 8, 9};

Zutabiek orduen arduinoko 2,3,4,5 pinetan konektakuz eta lerruek 6,7,8,9 pinetan.

Programie konpileteko Keypad.h, baie trankil ogon dana dau te neure github-en ;)

Eztakulez LCD-rik edo ikusteko ze tekla gabiltzen joten, konsolan idazten’du, konsolie igiritzeko lupe ikonuen egin klik:

https://img.imgur.com/gMFaa4Y.png

eta haulako lehidxo bat agertuko da, oin jo teklari eta ikusku zelan duen konsolie letra eta zenbakidxekaz beteten:
https://img.imgur.com/5egyU5X.png

Kodigo dana neure github kontuen:
https://github.com/zital/arduino

debian -en whatsapp pidgin -egaz erabiltzeko

2013/11/14 Eguneratute: Zenbakidxe desaktibe doztie! Bezero ez ofizialak erabiltziarreitzik:

http://www.whatsapp.com/faq/general/23154266

2013/10/07 Eguneratute: WART-1.5.1.0.exe bertsiñora!

Whatsapp ordenadoran erabiltzeko, gure kasuen pidgiñegaz:

Lehenengo erregistre ein biko gara, horretarako WART programie erabilku, .NET -entzako dau einje baie mono -gaz erabili lei:

su
aptitude install libmono-system-core4.0-cil libmono-system-windows-forms4.0-cil mono-runtime
exit

wget https://github.com/shirioko/WART/raw/f27b6326c8552fe134f9684d5e5876e1c28be0f7/WART-1.5.1.0.exe
mono WART-1.5.1.0.exe ui

https://img.imgur.com/fbD3iPl.png

Oin Phone number atalien geure mobilen zenbakidxe sartungu 34 -gaz aurretik + barik, adibidez:

34666111222

SMS eta Voice aukeratan: SMS hartungu eta Request Code botoie jo.

Lehenengo bidarra bada mobilera SMS bat allegako dasku, holako formatuegaz:

XXX-XXX

Horrek 6 digituek – barik programako Code atalien sartunguz eta Confirm code jo.

Found password:
ABCd1234567fGhIJkLmNOP+qRst=

Write it down and exit the program

Oin pidgin instalaku eta whatsapp-eko plugine beran pluginen karpetan sartun:

su
aptitude install pidgin
cd /usr/lib/pidgin/
wget http://davidgf.net/nightly/whatsapp-purple/x64/last-whatsapp.so
mv last-whatsapp.so whatsapp.so
exit

i386 badakozuie:

wget http://davidgf.net/nightly/whatsapp-purple/386/last-whatsapp.so

Oin pidgin igiriku:

kontuak -> kontuak kudeatu -> + Gehitu:
Protokoloa: whatsapp
Erabiltzailearen izena: 34666111222
Pasahitza: ABCd1234567fGhIJkLmNOP+qRst=
eta + Add jo.

Oin banan banan sartun bidiez lagunek 34gaz telefonuen aurretik:

Lagunak -> laguna gehitu
Lagunaren erabiltzaile izena: 34666222333
eta + Add jo.

WART -en github proiektue
https://github.com/shirioko/WART

whatsapp-purple -en github proiektue:
https://github.com/davidgfnet/whatsapp-purple

web.py nginx-egaz erabiltzeko fastcgi moduen spawn-fcgi-gaz debian gnu/linux-en

Instalaziñue:

su
aptitude install nginx-full spawn-fcgi python-pip
pip install web.py
exit

Proiektuentzako karpeta bat sortu, adibidez:

mkdir /home/projects/zpy
mkdir /home/projects/zpy/private
mkdir /home/projects/zpy/public
mkdir /home/projects/zpy/public/static
touch /home/projects/zpy/private/zpy.py

Haulako estrukturie okingo lekidau:

.
????????? private
???   ????????? zpy.py
????????? public
    ????????? static

Oin python-en script-e fcgi moduen erabiltzeko:

nano /home/projects/zpy/zpy.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import web

urls = ("/.*", "zpy")
app = web.application(urls, globals())

class zpy:
    def GET(self):
        return "kaixo mundua!"
        
if __name__ == "__main__":
    web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr)
    app.run()

Baimenak emon:

chmod +x /home/projects/zpy/zpy.py

FCGI demoniñue sortu:

su
nano /etc/init.d/spawn-fcgi
#! /bin/sh
### BEGIN INIT INFO
# Provides:          spawn-cgi
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: fastcgi for python
# Description:       fastcgi for python using nginx
#                    placed in /etc/init.d.
### END INIT INFO
#
# original https://gist.github.com/ozeias/47394
# modified to use with python
#
# to install in debian gnu/linux:
# update-rc.d spawn-fcgi defaults
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/spawn-fcgi
NAME=spawn-fcgi
DESC=spawn-fcgi

HOST='127.0.0.1'
PORT=9000

FOLDER='/home/projects/zpy/private'
SCRIPT='zpy.py'
USER='zital'
GROUP='zital'

DAEMON_OPTS="-d ${FOLDER} -f ${FOLDER}/${SCRIPT} -a ${HOST} -p ${PORT} -P /var/run/${NAME}.pid -u ${USER} -g ${GROUP}"
 
test -x $DAEMON || exit 0
 
set -e
 
case "$1" in
	start)
		echo -n "Starting $DESC: "
		start-stop-daemon --start --exec $DAEMON -- $DAEMON_OPTS
	;;
	stop)
		echo -n "Stopping $DESC: "
		start-stop-daemon --stop --pidfile /var/run/$NAME.pid
	;;
#	restart)
#		echo -n "Restarting $DESC: "
#		start-stop-daemon --stop --quiet --pidfile \
#		/var/run/$NAME.pid --exec $DAEMON
#		sleep 1
#		start-stop-daemon --start --quiet --pidfile \
#		/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
#		echo "$NAME."
#	;;
	*)
		N=/etc/init.d/$NAME
		echo "Usage: $N {start|stop}" >&2
		exit 1
		;;
	esac
 
exit 0

demoniñue martxan imiñintzeko:

update-rc.d spawn-fcgi enable
update-rc.d spawn-fcgi defaults
/etc/init.d/spawn-fcgi start
exit

Haulako zeuzer agertuko dasku:

Starting spawn-fcgi: spawn-fcgi: child spawned successfully: PID: 4619

Oin nginx konfigureku:

su
nano /etc/nginx/sites-available/python
server
{
	listen 80 default_server;
	listen [::]:80 default_server ipv6only=on;

	# Make site accessible from http://localhost/
	server_name localhost;

	location /static
	{
		root /home/projects/zpy/public;
		if (-f $request_filename)
		{
			rewrite ^/(.*)$  /$1 break;
		}
	}

	location /
	{
	        fastcgi_param REQUEST_METHOD $request_method;
	        fastcgi_param QUERY_STRING $query_string;
	        fastcgi_param CONTENT_TYPE $content_type;
	        fastcgi_param CONTENT_LENGTH $content_length;
	        fastcgi_param GATEWAY_INTERFACE CGI/1.1;
	        fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
	        fastcgi_param REMOTE_ADDR $remote_addr;
	        fastcgi_param REMOTE_PORT $remote_port;
	        fastcgi_param SERVER_ADDR $server_addr;
	        fastcgi_param SERVER_PORT $server_port;
	        fastcgi_param SERVER_NAME $server_name;
	        fastcgi_param SERVER_PROTOCOL $server_protocol;
	        fastcgi_param PATH_INFO $fastcgi_script_name;

	        fastcgi_pass 127.0.0.1:9000;
	}
}

Defektuzko konfiguraziñue kendu eta python-ena imiñi:

rm -rf /etc/nginx/sites-enabled/*
ln -s /etc/nginx/sites-available/python /etc/nginx/sites-enabled/python
/etc/init.d/nginx restart

Oin kontutan okin estatikoren bat gurebazuien sartun, js, css etc… “static” karpeta barruen sartun biherko dala, “public” karpetan eztau balijoko, adibidez:

“/public/a.txt” eztau balijoko
“/public/static/a.txt” bai balijoko dau :)

Eskerrak:

https://gist.github.com/ozeias/47394 spawn-fcgi-n demonidxuegaitzik :)