About GPIO, I post a blog when I start VoCore.
Please check this link http://vonger.cn/?p=473.
There is some note about how to finish this:
Connection:
That 330ohm resistor is necessary, without it, the LED will burn.
Command:
Already in this post http://vonger.cn/?p=473.
Advance:
We can write an API for this LED control, so we can simply control it from browser remotely phone, computer, pad, anything have broswer.
Here is the code, based on VoWeb, just add one function:
int voweb_func_gpio0ctrl(socket_data *d, string_reference *pa) { char buf[MESSAGE_SIZE] = "Invalid parameter."; FILE *fp; fp = fopen("/sys/class/gpio/gpio0/direction", "w"); if(fp == NULL) { sprintf(buf, "update gpio 0 direction failed."); return send(d->sock, buf, strlen(buf), 0); } fwrite("out", 1, 4, fp); fclose(fp); if(memcmp(pa->ref, "on", 2) == 0) { fp = fopen("/sys/class/gpio/gpio0/value", "w"); if(fp != NULL) { fwrite("1", 1, 2, fp); fclose(fp); sprintf(buf, "update gpio 0 value to 1 success."); } else { sprintf(buf, "update gpio 0 value to 1 failed."); } } if(memcmp(pa->ref, "off", 3) == 0) { fp = fopen("/sys/class/gpio/gpio0/value", "w"); if(fp != NULL) { fwrite("0", 1, 2, fp); fclose(fp); sprintf(buf, "update gpio 0 value to 0 success."); } else { sprintf(buf, "update gpio 0 value to 0 failed."); } } return send(d->sock, buf, strlen(buf), 0); }
And register this function:
string_hash_set(funcs, "gpio0ctrl", (uchar *)voweb_func_gpio0ctrl);
Here is compiled one and necessary html: download
Uncompress vocore.voweb.gpio.test.zip to local folder, such as “~/voweb.gpio”, and scp all of the files to root@192.168.61.1:~/
scp -r ~/voweb.gpio/* root@192.168.61.1:~/
Then run command in vocore.
/root/voweb 8080 /root/html
Just open 192.168.61.1:8080, you will find this page, now, just click on the switch, the LED is under your control.
Here is a simple video:
Any questions, just leave a comment under.
brandonhead, I like your question