Making use of 8x8x8 led cube

I followed this guide http://www.instructables.com/id/Led-Cube-8x8x8/ for making 8x8x8 led cube and I wanted a better way of starting animations so I connected the buttons to the GPIO of the RaspberryPI so I can start animation whit tasker.

I have connected gpio pins to the buttons on the 8x8x8 led cube so that I can start rs232 mode, reset and start animations on the cube from internet.

nano shutdowncheck

gpio export 2  output
gpio export 29 output
gpio export 31 output

gpio -g write 29 1
gpio -g write 31 1
gpio -g write 2  1

http://www.youtube.com/watch?v=ocUBnr-OMKc

curl https://username:password@domain.com/client.php?cmd=MAIN_BTN –insecure
——————————————————-
BUTTON       ||  Port      || Pin nr    ||  GPIO pin   ||
——————————————————-
MAIN_BTN    || PINB4    ||    5       ||  29            ||
RS232_BTN  || PIND5    ||   19      ||  31            ||
RESET_BTN  || RESET    ||    9       ||  2              ||
——————————————————-

<?php
require( __DIR__ . '/lib/ElephantIO/Client.php');
use ElephantIOClient as ElephantIOClient;
$elephant = new ElephantIOClient('http://localhost:8080', 'socket.io', 1, false, true, true);
$elephant->init();
$elephant->emit($_GET["cmd"], $_GET["cmd"]);
$elephant->close();
?>

  socket.on('MAIN_BTN', function (data) {
console.log(data.toString());
Pressbutton('RESET_BTN', 100);
setTimeout(function() {
Pressbutton('MAIN_BTN', 100);
}, 200);
});

socket.on(‘RS232_BTN’, function (data) {
console.log(data.toString());
Pressbutton(‘RESET_BTN’, 100);
setTimeout(function() {
Pressbutton(‘RS232_BTN’, 100);
}, 200);
});

socket.on(‘RESET_BTN’, function (data) {
console.log(data.toString());
Pressbutton(‘RESET_BTN’, 100);
});

function Pressbutton(btname, delay)
{
switch (btname)
{
case ‘MAIN_BTN’:
wpi.digitalWrite(29, wpi.LOW);
break;
case ‘RS232_BTN’:
wpi.digitalWrite(31, wpi.LOW);
break;
case ‘RESET_BTN’:
wpi.digitalWrite(2, wpi.LOW);
break;
}

setTimeout(function() {
wpi.digitalWrite(29, wpi.HIGH);
wpi.digitalWrite(31, wpi.HIGH);
wpi.digitalWrite(2,  wpi.HIGH);
}, delay);
}

 

Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *