abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

The Pi Co-op - an Arduino Add-on Board for the Raspberry Pi

Sat Mar 15, 2014 11:06 am

Hi all,

The Pi Co-op from Dawn Robotics is an easy to use Arduino add-on board for your Pi, on sale here.

We've created a video showing what it is, and why you might want to buy one here.

Also, we've published a tutorial here showing how you can use Firmata to control the Pi Co-op from a higher level language like Python or Javascript. This essentially turns the Pi Co-op into a really easy to use general purpose I/O board. An Analog to Digital Converter (ADC), 5V I/O pins, PWM signal generation and much more, all in one board. :)

Any questions, or constructive comments, much appreciated.

Regards

Alan

Image

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 15, 2014 12:54 pm

looks interesting … I've done a fair bit of software or web stuff over 30 years, but seem to have a block on the bare metal aspects of Pi use. I think because I've done so little physical electronics. The 3.5/5v thing has been a cause of caution, partly from stories of dead kit here. Your documentation is rather patchy. A few straight questions then

1. Does this essentially make all i/o into 5 volt?
2. video suggests I plug 5v into the co-op and the Pi powers from that?
presumably down the header pins, is this so?
3. to be clear, the Pi controls the co-op via the UART pins, the riser on the
card are from its own chip? Does this mean that the Pi pins are unavailable?
4. How is an ADC voltage read?
5. what do those female sockets on the board do, is there a map/graphic?
6. six ;) male risers in the graphic above, what do those do?
7. is that a switch? What does that do?

TIA Chris

[edit] googling a bit … firmata doesn't seem all that well documented either. In essence I want to understand what the pins on the co-op are/do and how the firmata protocol sets/reads them

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 15, 2014 3:11 pm

Sorry to be verbose, but this looks interesting. Here's a uno descriptor off the web "Input and Output"

Each of the 14 digital pins on the Arduino Uno can be used as an input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have specialized functions:

Serial: pins 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip.

External Interrupts: pins 2 and 3. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the attachInterrupt() function for details.

PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.

SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the SPI library.

LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value, the LED is on, when the pin is LOW, it’s off.

The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution (i.e. 1024 different values). By default they measure from ground to 5 volts, though is it possible to change the upper end of their range using the AREF pin and the analogReference() function. Additionally, some pins have specialized functionality:

TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using the Wire library.

There are a couple of other pins on the board:

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields which block the one on the board.


clearly fewer io's but a pretty useful number. What of the above does it do, or not do please?

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 15, 2014 8:29 pm

Hi Chris,

Thanks for the questions. The documentation is a bit sparse I'm afraid, but I'm looking to improve it all the time, and your questions give me some good pointers to areas which need to be expanded. :)

Basically, the Pi Co-op is an Arduino Uno, just one that's more integrated with the Raspberry Pi. All you really need to make an Arduino Uno is an Atmega328 microcontroller, an oscillator, and the open source Arduino bootloader (a program that sits on the Atmega328, and allows it to be programmed over the serial pins). Therefore, anything the Arduino Uno can do software wise, the Pi Co-op can do also. In fact, the Pi Co-op has a slight advantage in that it has 8 analog inputs, whereas a standard Arduino Uno has only 6 (this is because the Uno uses the DIP package Atmega328, and the Pi Co-op uses the surface mount Atmega328).

Keeping in mind that the Pi Co-op is really an Arduino Uno, this makes it a bit easier to answer your questions

1. Does this essentially make all i/o into 5 volt?

Yes, this is because the Atmega328 runs at 5V, and communicated with the Pi using serial. Therefore only the RX/TX lines between the Atmega328 and the Pi need to be level shifted.

2. video suggests I plug 5v into the co-op and the Pi powers from that?
presumably down the header pins, is this so?

Yes, 5V plugged into the Co-op would power the Atmega328 and then go through the fuse to power the Pi. The voltage does need to be regulated 5V, so putting in too high a voltage will still probably damage your Pi, but the fuse should protect the Pi from current spikes when running at 5V.

3. to be clear, the Pi controls the co-op via the UART pins, the riser on the
card are from its own chip? Does this mean that the Pi pins are unavailable?

Yes, yes, and yes. Although we do hope to offer the option of being able to buy the Pi Co-op without the headers soldered on very soon, so that if you wanted too, you could solder on your own extended header pins to get access to the rest of the Pi GPIO pins. We did look at the option of using extended header pins as standard, but it seemed tough to get them at good wholesale prices without buying a really massive quantity of them.

4. How is an ADC voltage read?

After connecting your signal to one of the ADC input pins you would either write an Arduino sketch using the AnalogRead function, as shown in this tutorial. Or alternatively, if you were using PyMata, then it would involve running a Python script something like the one in this pymata_analog_read.py example.

5. what do those female sockets on the board do, is there a map/graphic?

Those sockets correspond to the sockets on an Arduino Uno, with some extra ones assigned to 5V and ground. You can get a clearer view in the image linked here.

6. six ;) male risers in the graphic above, what do those do?

That is the programming header for the Atmega328. You can use it to program the Atmega328 directly (as opposed to using the Arduino bootloader) by using a programmer such as this one.

7. is that a switch? What does that do?

That is the Arduino reset switch. It could possibly also be read from the GPIO pin used to reset the Arduino from the Pi, although I'd need to check that.

Overall, I believe that combining an Arduino with a Raspberry Pi gives a lot of power and flexibility, in that you have a microcontroller which can do a lot of things for you hardware wise, ADC, level shifting, PWM etc. It can also run general purpose code, which can be very useful if you want to do something and guarantee that it isn't interrupted by another thread etc. Unfortunately, this power and flexibility does come at the price of extra complexity, in that there needs to be serial communication between the Pi and Arduino in order to coordinate things. That's why I've tried to emphasize the use of PyMata, as it can hide a lot of that complexity.

Anyway, if you've made it to the end of this fairly lengthy post, hopefully that makes things a bit clearer. :)

Regards

Alan

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Pi Co-op - an Arduino Add-on Board for the Raspberry Pi

Sun Mar 16, 2014 7:53 am

Thanks, exactly the answer I needed. I need to do a bit of preparatory work to make my Pi LAN, as opposed to UART headless; but after that I think you may expect an order.

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Tue Mar 18, 2014 6:38 pm

Came two days later. it is nicely smaller than a "shield" and basically covers about 40% of the Pi board, in from the pins. A 26 way female engages these nicely, the rest of the add-on rests on that famous capacitor on the other side via a silicone rubber blob. I think any pressure there will be small as the reset button is riser side of it.

The female input/outputs are a couple of mm proud of my case, so I cut a hole (Stanley knife, took about 20 minutes). Slight anxious moment on power up, I think boot is a little slower but as I've converted to LAN headless to try this I don't see the boot monologue any more. Eventually I got a ping and puTTy connected nicely. All seems well.

So now all my bare metal i/o is 5v and I feel a lot braver. It's already got me LAN headless. Downsides are that the pins are now hidden (or is that an upside?) and that my UART is committed. Everything will be slower, ms instead of μs, no problem chez moi. Wish me luck. Picture attached. Yes, its a real bread board.
Attachments
image.jpg
coopi board as fitted, hole cut for it in Maplin box
image.jpg (59.16 KiB) Viewed 7938 times

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Wed Mar 19, 2014 12:03 pm

Hi Chris,

Looks very nice, and thank you for your order. :)

Interested to know how you get on with it. Any problems, or if there's any extra information you need, just gimme a shout.

Regards

Alan

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 9:36 am

Thanks. I attach a pic (in the orientation I get to see it) and have the female pins well sorted. The 6 pin riser I am not so sure about. Guess I could probe about with a meter with it switched on, but

1. are the P10 riser pins as per the insert from your schematic?
2. They contain an SPI bus? So is that off-board, or from the Pi GPIO?

. If it is off the board, how is it controlled?
. If off the Pi .. presumably shifted to 5V .. or not?
Attachments
coop3.jpg
Board as see from end of PI, GPIO to the left
coop3.jpg (37.18 KiB) Viewed 7808 times

User avatar
DougieLawson
Posts: 36569
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 9:46 am

The six pin riser is the standard Arduino/Atmel AVR ICSP interface.
You should get MOSI, MISO, SCK, RESET, VCC, GND on there.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 10:19 am

Thanks, as labeled in the insert ;)

But is the SPI directly controlled by the Pi's GPIO, or what?

. :? and, er, which pin is which?

User avatar
DougieLawson
Posts: 36569
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 11:03 am

Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 1:07 pm

Hi there,

Yes, as Dougie kindly pointed out. This is a standard ISP programming header, which you would connect to using a programmer such as this one. The pins are connected directly to the Atmega328. In general when reading a schematic, pins which have the same name are connected to each other, but the connections aren't shown to try to keep things readable.

You shouldn't need to use the programming header, as the Arduino bootloader has already been put on it, and this allows for programming via the UART lines. Situations in which you might want to use a programmer are if you wanted to reflash the Arduino bootloader for some reason, or if you had a program that used up so much space, that you needed to reclaim the 2K or so used by the bootloader.

Ideally I should also have put some markings on the silkscreen to identify the correct way to plug in the programming header, but you have the correct orientation. You can see the reset line going to the reset button, and if you turn the board over, you should see that the ground pin is connected by a couple of small 'spokes' to the ground plane.

Regards

Alan

gandar
Posts: 215
Joined: Sat Feb 01, 2014 5:45 pm

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 1:08 pm

For those new to the community including me, is this an arduino, an arduino replacement, or just a bridge between your pi and an arduino?

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 1:10 pm

Hi Gandar,

This is effectively an Arduino Uno, that connects directly to the GPIO pins.

Regards

Alan

User avatar
DougieLawson
Posts: 36569
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 1:17 pm

Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 2:21 pm

Would seem to be offered mainly as an I/O expander here - see the "other" thread on this "Using an Arduino as a slave I/O board" http://www.raspberrypi.org/forums/viewt ... 44&t=46881

It would seem that you can however ignore the GPIO riser, and use it on its own powering into the 5V rail, though I guess that'd need different firmware.

Does the above mean that the SPI lines are inaccessible to the Pi?
chrisryall wrote: If it is off the board, how is it controlled?
. or are you saying that this six-pin is there merely to program the board (viz in a non Pi manifestation)?

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 5:14 pm

Hi Chris,

In this situation, the SPI lines can't talk to the Pi. The Arduino can communicate using SPI to other devices, but all communication between the Pi and the Arduino on the Pi Co-op is limited to serial UART.

The SPI lines could be connected to the Pi, but we took the decision not to just because that would have involved more level shifting logic, and we were trying to keep things as simple as possible. Hopefully, as I say, we'll release a version without headers soldered on at some point, so people could use an extended GPIO header pin to access the Pi's SPI pins and wire this up if they wanted to.

Regards

Alan

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 5:21 pm

DougieLawson wrote:Here's my version: http://www.raspberrypi.org/forum/viewto ... 46&t=50744
Ah cool, I hadn't seen that one.

There are indeed, many, many Arduino add-on boards for the Pi out there. I think that incorporating an Arduino appears as quite a logical step when trying to integrate the Pi with external electronics. Our aim with the Pi Co-op was really to offer a nicely integrated Arduino, that was as easy to use as possible, hence the focus on Firmata and PyMata which we talk about in this blog post.

Also, if you consider that we're a robotics company with some Arduino robot kits that we'd like to get working with the Raspberry Pi, then our plans for world domination should become clear. ;)

Regards

Alan

Image

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat Mar 22, 2014 5:32 pm

chrisryall wrote:. If it is off the board, how is it controlled?
Sorry, missed this part. It looks like SPI isn't currently supported by Firmata, although there is a proposal to add it.

You can however make use of SPI by writing you own Arduino sketch and using the Arduino SPI library. Serial communication back to the Pi is also easy using the Arduino serial library, and then you'd use a serial library in the language of your choice to control it.

Regards

Alan

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sun Mar 23, 2014 10:22 am

Thanks Alan. I rose with the lark this morning :D My desktop interface via xming is a little bit slow so I used the methods in your Appendix A, double checking everything (as you do). The (recommended test) blink module compiles and and I got a nice Xming pop up window in desktop. Did what the progress bar gets to about 90%. There it hangs. After about 10 minutes I hit ctrl-C. Then I tried again and went off to watch Andrew Marr .. on return it had autokilled. Logs etc attached below in case you can see an obvious flaw. I still feel optimistic as it's only falling at the last hurdle; but I'm not sure why :(

After entering pi~> arduino [compiling sketch pause .. a mere 25s]

Code: Select all

Binary sketch size: 1,072 bytes (of a 32,256 byte maximum)
[Uploading] ... ... [about 10 minutes] ^C

Code: Select all

Traceback (most recent call last):
  File "/usr/bin/autoreset", line 39, in <module>  process()
  File "/usr/bin/autoreset", line 30, in process  input = sys.stdin.readline().strip()
KeyboardInterrupt
Traceback (most recent call last):  File "/usr/lib/python2.7/site.py", line 68, in <module>
Traceback (most recent call last):  File "/usr/bin/autoreset", line 39, in <module>  process()
  File "/usr/bin/autoreset", line 30, in process  input = sys.stdin.readline().strip()
KeyboardInterrupt
Traceback (most recent call last):
  File "/usr/bin/autoreset", line 39, in <module>   process()
  File "/usr/bin/autoreset", line 30, in process
[Tried again ... same hang happened ... sometime in next hour]

Code: Select all

/usr/bin/arduino: line 33:  2991 Killed ..
  java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel ..
   processing.app.Base "$@"
FILE DUMPS /boot/cmdline.txt reads

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
LAST LINES of /etc/inittab are

Code: Select all

# Example how to put a getty on a serial line (for a terminal)
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
# Example how to put a getty on a modem line.
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
#Spawn a getty on Raspberry Pi serial line
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
/etc/udev/rules.d/99-pi_co-op_tty.rules reads (not sure I like that :? "dialout" !!

Code: Select all

KERNEL=="ttyAMA0",SYMLINK+="ttyS0" GROUP="dialout"
KERNEL=="ttyACM0",SYMLINK+="ttyS1" GROUP="dialout"

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sun Mar 23, 2014 10:28 am

...
Just to add that the whole Pi in hung at this point! I get my linux "Pi~>" prefix, but all keyboard input (including ctrlC/D/X) resulted only in a line feed. Shutting the PuTTy window allowed a successful re-login, which seems entirely normal. TIA

[ed] In case anyone else is following this, here's a " very friendly" review in "another place"
. . . . http://www.recantha.co.uk/blog/?p=8865

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sun Mar 23, 2014 8:25 pm

Hi Chris,

Apologies for the late reply to this, I've been out all day.

It looks for some reason as if the code to reset the Arduino (and thus prepare the bootloader to receive code) is not being called. I'm a bit confused though, is this the same SD card that you've been running the PyMata examples on?

Also, I take it from the fact that you're following the Appendix that you're not running Raspbian? Which distribution and version are you using so that I can have a go at reproducing the bug?

Cheers

Alan

User avatar
chrisryall
Posts: 155
Joined: Wed Nov 27, 2013 11:45 am
Location: Wirral UK
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sun Mar 23, 2014 9:49 pm

no problem, I've been out all day too.
1
I bought my Pi in November and found the HDMI interface absolutely horrible on a small Wifi keyboard and my TV. after some advice here [thanks] I installed the UART interface which has worked very well. In order to make "co-op" work I "obviously" needed another interface and I got the PuTTy SSH LAN address sign in system working in order to use it. That xming made your arduino system pop up windows on Windows. and seemed a nice bonus.

My SD card is a raspian download in late November; as updated every week or so. i "think" I did all the mods on your appendix A. I updated apt-get update to the latest system this morning, (as instructed) So far i've never had opportunity to run a working pymata. So, I guess, current build? Your own software was downloaded "as per PDF" at approx 8 am this morning.

abroun
Posts: 31
Joined: Sat Jun 29, 2013 10:13 am
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Mon Mar 24, 2014 10:54 am

Hi Chris,

If you've got a spare SD card available, could you try using the current version of Raspbian (2014-01-07-wheezy-raspbian.zip) and then following the steps in the 'Simple Installation Process' section? I've just done this at my end and everything works fine.

The script run in the Simple Installation Process just carries out the steps detailed in the Appendix so I'm thinking that there could be a small mistake or omission in the list of instructions, or perhaps something wasn't conveyed well enough for when you were following them. Either way, if we could test to see if the installation script works then we could hopefully see if it's a problem with the software setup or the hardware.

Also, just on the off chance that it's something simple. Can you check that it definitely says 'Arduino Uno on /dev/ttyS0' in the bottom right corner of the Arduino IDE? Also, can you check that the Pi Co-op is definitely on the GPIO pins correctly and not one row up or down?

Regards

Alan

User avatar
QBall1977
Posts: 77
Joined: Thu Aug 09, 2012 10:06 am
Location: Hull, East Yorkshire
Contact: Website

Re: The Pi Co-op - an Arduino Add-on Board for the Raspberry

Sat May 17, 2014 12:07 am

Alan,

Any chance you can help. I'm an Arduino newbie. But basically I followed another tutorial to hack some IKEA DIODER Lights, you remove the controller, wire to Red, Green, Blue, a common ground and common +5v. The following .ino works when uploaded via the Arduino IDE... :P
**********************************************************************************************
// color swirl! connect an RGB LED to the PWM pins as indicated
// in the #defines
// public domain, enjoy!

#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3

#define FADESPEED 5 // make this higher to slow down

void setup() {
pinMode(REDPIN, OUTPUT);
pinMode(GREENPIN, OUTPUT);
pinMode(BLUEPIN, OUTPUT);
}

void loop() {
int r, g, b;

// fade from blue to violet
for (r = 0; r < 256; r++) {
analogWrite(REDPIN, r);
delay(FADESPEED);
}
// fade from violet to red
for (b = 255; b > 0; b--) {
analogWrite(BLUEPIN, b);
delay(FADESPEED);
}
// fade from red to yellow
for (g = 0; g < 256; g++) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
}
// fade from yellow to green
for (r = 255; r > 0; r--) {
analogWrite(REDPIN, r);
delay(FADESPEED);
}

// fade from green to teal
for (b = 0; b < 256; b++) {
analogWrite(BLUEPIN, b);
delay(FADESPEED);
}
// fade from teal to blue
for (g = 255; g > 0; g--) {
analogWrite(GREENPIN, g);
delay(FADESPEED);
}
}

**********************************************************************
I was hoping to have similar control over the LEDs using the PyMata, however I'm having trouble finding an example that uses PWM and allows analog writes. :?

I thought something like this would work but it seems to output nothing. Do you have any suggestions?

***************************************************************************************
import time

from PyMata.pymata import PyMata
# Give the pins names:
REDPIN = 5
GREENPIN = 6
BLUEPIN = 3

FADESPEED = 5

# Create an instance of PyMata.
SERIAL_PORT = "/dev/ttyS0"
firmata = PyMata( SERIAL_PORT, max_wait_time=5 )

# initialize the digital pin as an output.
#firmata.set_pin_mode( LED, firmata.OUTPUT, firmata.DIGITAL )
firmata.set_pin_mode( REDPIN, firmata.OUTPUT, firmata.PWM)
firmata.set_pin_mode( GREENPIN, firmata.OUTPUT, firmata.PWM)
firmata.set_pin_mode( BLUEPIN, firmata.OUTPUT, firmata.PWM)

try:
# run in a loop over and over again forever:
while True:
#for r in range (0,256,1):
firmata.analog_write( REDPIN, 255 )
firmata.analog_write( GREENPIN, 0 )
firmata.analog_write( BLUEPIN, 255 )
time.sleep(1.0) # wait for a second

except KeyboardInterrupt:

# Catch exception raised by using Ctrl+C to quit
pass

# close the interface down cleanly
firmata.close()
____________________________________________
Looking for where to start - try Kernel Panic - http://goo.gl/EEQ5J

Return to “For sale”