Page 1 of 1

Dagu Arduino Mini Driver

PostPosted: Sat Jan 10, 2015 11:13 pm
by beppeIT
I bought the Raspberry Pi Camera Robot and I was wondering if, considering that is loaded on the Dagu Arduino Mini Driver al boot, it is possible to send commands to use digital outputs in order to turn on leds.

I mean, I would like to give "light" to the camera in dark areas, and wondering:
- where to connect leds
- how to control them from web interface with the addition of a button.

Any hints?

thx
Beppe

Re: Dagu Arduino Mini Driver

PostPosted: Mon Jan 12, 2015 1:01 pm
by Alan
Hi Beppe,

This would involve making changes at 5 levels. Apologies in advance for the complexity. It's a side effect of trying to abstract away lower level details so that people can get started with driving their robot around, or controling it with a script running on a remote computer more quickly.

Anyway, at a very high level, the changes you need to make are

First add some code to mini_driver_firmware.ino. I recommend perhaps modifying the way that the sensor configuration works so that you can set the digital pins to outputs. Otherwise you'll find that they're constantly set back to inputs. Whilst changing the firmware then if you update VERSION_MAJOR or VERSION_MINOR at the top then the firmware will automatically be built and uploaded to the mini driver when the web server starts.

Secondly, modify mini_driver.py so that it can send the correct message down to your modified firmware to control the digital outputs. At the same time add something like a 'setDigitalOutput' routine to the MiniDriver class.

Thirdly, modify robot_controller.py to have a 'setDigitalOutput' routine that passes the data onto the mini driver.

Fourthly, modify robot_web_server.py to add a setDigitalOutput command to the web sockets interface. This is done by editing the on_message routine (line 83 onwards) in the ConnectionHandler class.

Finally, you can now modify the web interface to call your new setDigitalOutput command via websockets.

Hopefully all of that is vaguely comprehensible, and hasn't frightened you too much. As an alternative that would probably take less work, I would suggest that you drive the LEDs from the Pi's GPIO pins. In this situation you will probably just need to take the 4th and 5th steps in that you can add some code to robot_web_server.py to talk to GPIO pins and expose it via web sockets.

Let me know if you need a bit more detail anywhere. :)

Regards

Alan

Re: Dagu Arduino Mini Driver

PostPosted: Mon Jan 12, 2015 8:31 pm
by beppeIT
Thank you I found out the first 2 steps in my own, but I did not go much beyond.
I am thinking of adding a light to the front of the robot that can be controlled from a button on the web interface.

just to know, what kind of application did you use to program the interface in html5?
thx
Beppe

Re: Dagu Arduino Mini Driver

PostPosted: Tue Jan 13, 2015 11:32 am
by Alan
Hi Beppe,

I used the kate text editor on Ubuntu to program the web interface, which is probably why it's so clunky. ;)

I'm afraid I'm not really that experienced in web design, javascript and HTML5 etc so it's mainly built by copying code snippets I found online and doing a lot of reading on W3Schools. This is one of the reasons all the code is open source though, I'm hoping that at some point someone who knows what they're doing will come along and help me improve it. :)

Regards

Alan