Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Sunday, June 12, 2011

#devel contest draft rules

It's contest time again, and more particularly, it's contest time for the #devel channel on irc.malvager.net

Draft Rules for the #devel contest of irc.malvager.net:


Create a tool that will either allow or otherwise encourage people in #devel to collaborate in code writing and or sharing. The platform/language can be any (within reason; if you’re not sure, ask). It will be judged subjectively by both bsdpunk and psycho on both functionality and creativity. The first place prize will be a bsdpunk t-shirt and an Arduino (or Arduino clone). The second place prize is an Arduino (or clone). If god willing a third place prize, tbd (this one is not written in stone).

Contest will be over on the 20th of July.


Draft rules are subject to change for the next week, keep updated by looking at this blog(rules will only change by minor stipulations, the spirit of the contest will remain the same).

Sunday, October 11, 2009

Some Bad photography of mine, and my nxt stuff

Suffer?


I took a couple shots of my NXT face I made. Video with functionality soon.

Saturday, October 3, 2009

Very Simple Tutorial for pygame and arduino, to get started making a gui for arduino part 1



This is how to get started, with python and your arduino, brining up the begginings of a GUI. It's just a taste of what you can do and I hope to go further on the subject. You need pygame, and the python firmata installed(explained here), and your arduino must have the firmata software on it as explained here. Here is the code I stole/wrote for getting the arduino to blink when you click within pygame. This outline should get you started with fun stuff:


#! /usr/bin/env python

import pygame
from firmata import *

proArduino = Arduino('/dev/ttyUSB0')
proArduino.pin_mode(13, firmata.OUTPUT)
proArduino.delay(2)

LEFT = 1
x = y = 0
screen = pygame.display.set_mode((640, 480))
running = 1

def blinky(pin_n):
proArduino.digital_write(pin_n, firmata.LOW)
proArduino.delay(2)
proArduino.digital_write(pin_n, firmata.HIGH)
proArduino.delay(2)


while running:
event = pygame.event.poll()
if event.type == pygame.QUIT:
running = 0
elif event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT:
blinky(13)

screen.fill((100,0,0))
pygame.display.flip()



Right now I am experimenting with a lot of diffrent things(forking etc.), to see how the arduino and pygame can best interoperate.

Prepping Fedora Core for NXT brick, and Arduino, to be used with pygame and mod_python, in a python environment

If you do a fresh install of Fedora 11, you just need to save this script and run it as root on your machine, once you have saved it with a .sh extenstion, open the terminal, use the command su to become root, then navigate to the directory you have saved it in. Change the permissions, before you try to run it, so it is executable. Run it by typing dot then slash the the script name: ./scriptname.sh

Before the script:
su
chmod 777 scriptname.sh


#! /bin/bash
yum -y install mod_python
mkdir -p /var/www/html/test
cat <<-EOF >/etc/httpd/conf.d/pythonTwo.conf
<Directory /var/www/html/test>
AddHandler python-program .py
PythonHandler mptest
PythonDebug On
</Directory>
EOF
cat <<-EOF >/var/www/html/test/mptest.py
#!/usr/bin/python
from mod_python import apache

def handler(req):
req.send_http_header()
req.write("Hello World!")
return apache.OK
EOF
yum -y install python-devel
yum -y install git
git clone http://github.com/lupeke/python-firmata.git
cd python-firmata
python setup.py install
yum -y install gcc
yum -y install pybluez
yum -y install nxt_python
yum -y install pygame
/usr/sbin/apachectl restart


**caveat**
Be careful where you save it, it will create a directory for the python-firmata in that directory. If you use this right when your machine boots, there is a possibility the yum updater will start using yum, if the script will pause until the updater is finished using yum then continue, or you can run it before you start the script.

Sunday, September 27, 2009

Blinking an LED over the web, with python firmata, php, and apache.



This was done on a mac, however it should be the same or very similar on a linux system as well. Either way you need a webserver with php running, and an arduino conneceted via ftdi(usb probably) to your computer. You will also need to install the python firmata module, which is pretty straight forward, and you can get that here: http://github.com/lupeke/python-firmata.

This is to show you how to make an led blink, using a web page you have coded, and an arduino. Why would I show you how to do something so insignificant? The idea, is that this would be a place to start, with any sort of, over the web arduino fun. There are a list of caveats at the end.

Open the arduino program, then select File->Examples->Firmata->Standard Firmata. Then upload this to your board. If you have problems uploading, be sure you have the right board and serial port selected under tools. My cpanel.php file looked like this:


<html>
<head>
</head>
<body>
<form action="cpanel2.php" method="post">
On <input type="radio" name="light" />Light
<input type="submit" />
</form>
<?php
$password = $_POST["password"];
$light_on = $_POST["light"];
if(isset($light_on)){
$execute_light = `/Users/dustycarver/python/led2.py`;
}
?></body>
</html>



$execute_light should equal the pathname to your python firmata file, and should be surrounded my backticks(`), not single quotes(').Your python file should look like this:


#! /usr/bin/env python
"""
Simple LED blinking example using Python Firmata
Copyright (C) 2008 laboratorio (info@laboratorio.us)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see .
"""

from firmata import *

a = Arduino('/dev/tty.usbserial-FTE4W74Q')
a.pin_mode(13, firmata.OUTPUT)
a.delay(2)

a.digital_write(13, firmata.HIGH)
a.delay(2)
a.digital_write(13, firmata.LOW)
a.delay(2)


You can see I stole the code from the python firmata example, however I took out the loop so it would do only one sequence of blinks. Your "a =" line should have the address of your Arduino device.

Caveats:
Obviously this has limitations, it has to negotiate the connection with the arduino each time and that's a lot of overhead, so this is probably a good way to get started on something like turning your lights on at home before you get there, and less real time stuff. I am working on a mod_python deal, so that the connection is ever present and will submit that, if it ever becomes fruitful.

Sunday, July 12, 2009

News in brief

This weekend was a total wash.I really thought I was going to master rails in a single sitting but it just wasn't in the cards for me. I don't know if rails is that complicated, or I am just dumb. Anyways I definetly have a much firmer grasp on rails now, and am just at a point where I can actually start hacking away at a web app. Yeah it took that long. I was going to impliment a pleasure/pain system in my nxt brick robot and have people be able to give it rewards based on what it was doing, through a rails application I thought it might be easier than perl simply because I knew that rails had a database abstraction layer.....Oh what I didn't know. Anyway, I rebuilt the next brick according to someone elses design as well, to get it more suited for such a task, however, the configuration I used couldn't turn left or right....DOH. So event that was a wash. I also came to the realization it's getting harder and harder for me to start popping out a simple perl script once or twice a week, without either repeating myself or not paying enough attention to the script or the writing. Normally what I produce on my blog posts are simple hacks you can do in a single sitting. It looks like that will be changing(though I am sure every now and then I will pop one out, just out of scratching my own itch). I will be concentrating more on ruby and still on perl as will with a minor in objective c and maybe just plain c from now on. That being said I am also going to start focusing more on computer security as well, as this was the original intention of the blog, the robotics stuff will still be there.
So Check out Leggor.de and in particular Herold's Truck, I will embed the video below. The video is very well produced and meticulous, if not a bit creepy at the same time.


Thanks to leggor.de, i found that there are indeed lego cad files, you can open them in a variety of programs, I have been using Lego digital designer and have found that that works best for me(Windows and Mac).

That being said I also revisted my strobe design on my arduino chip, and relized that, that post is badly written and the code is worse, so here is some corrected code, with the caveat of this design probably needs to be calibrated using the serial monitor based on the lighting in the room:


#define LED 13 // LED connected to digital pin 13

int val = 0;
void setup()
{
pinMode(LED, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
}

void loop()
{
val = analogRead(0);
Serial.print(val);
Serial.print('\r');
if(val < 13) {
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(100);
digitalWrite(13, HIGH);
} else {
digitalWrite(13, LOW);
}
}


That being said, my hubris has raised the chance of a real technical post for this weekend to about 99 percent fail, I am still going to try and crank something out but who knows.

Old Arduino Strobe post

PS

I built alpharex wrong, I'm sorry.

Sunday, May 3, 2009

Making a strobe light with a Duemilanove 328 Arduino, should work with any arduino though



***EDIT The code in this kind of sucks so I corrected here. July 13th 2009***

Caveat: If you have the new Duemilanove you need to go to tools and set it for the ATMEGA 328 chip instead of the Duemilanove. Otherwise it will say something to the effect of: Programmer is not responding.----This may only be a mac problem.

I made this strobe, using a sketch from the "Getting Started with Arduino" book. On the arduino the connections are to GND, 5V, and Analog 0. Here is the orignal sketch code:


#define LED 13 // LED connected to digital pin 13

int val = 0;
void setup()
{
pinMode(LED, OUTPUT); // sets the digital pin as output
}

void loop()
{
val = analogRead(0);
digitalWrite(13, HIGH); // sets the LED on
delay(val); // waits for a second
digitalWrite(13, LOW); // sets the LED off
delay(val); // waits for a second
}


Here is my finished sketched code:


#define LED 13 // LED connected to digital pin 13

int val = 0;
void setup()
{
pinMode(LED, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
}

void loop()
{
val = analogRead(0);
if (val < 50) {
val = val + 60;
digitalWrite(13, HIGH);
delay(val);
Serial.print(val);
Serial.print('\r');
digitalWrite(13, LOW);
delay(val);
Serial.print(val);
Serial.print('\r');
} else {
digitalWrite(13, LOW);;
}

}


So my interesting idea for this project, was what if you hooked a motor to it, and programmed it to only move when it was going to wards light and rather than usb powered, used solar power, then you would have created something that has a will to survive.

Saturday, April 25, 2009

Hacker Crib...that's right, books and stuff, computers, arduino, nxt brick...I am not a nerd, I am a hacker....in my grandma's basement...damnit



I was trying to make an explanation video of why some of my shit doesn't get done as fast as I predict on the blog....And yeah this video doesn't really show that or anything....le sigh.

Monday, March 9, 2009

The current and the future of the blog.


As for the future:
I am Going to finish up the ssl sniffing traffic tutorial and add some arduino stuff. The SSL stuff might be a little while because I am thinking about buying a new machine, and if I do that I am going to do a How to build a computer youtube video, because those things seem to get a lot of hits. I want to do another t-shirt give away so if you have ideas for what kind of contest, please post a comment. Or if you have an idea for a diffrent kind of promotional event let me know.

As for the present:
I went to Podcamp 2009, so that was fun. Didn't talk to as many people because I have hard time approaching people, but I gave an interview, about something to somebody, so if anyone see's me on vlog or podcast or something, let me know. They had free beer starting at 11:30, so I was exahusted by 3:00. If I go again I am going to speak, I think. Got stood up for lunch, which was at Noshville. And whoever missed it, was lucky. The menu was incredibly expensive to begin with, and I was over charged for my plate. And apparently according to my guest the Greek Salad, wasn't so great. The Reuban dog, was good though(not nearly worth the 5 bucks on the menu or the 10 bucks I was charged for it, but whatever).