Justwondering321
Posts: 58
Joined: Mon Jul 16, 2012 6:39 am

Arduino language...

Fri Aug 03, 2012 8:28 pm

Hey guys, would it be possible to use the arduino language on the pi to control the GPIO pins??? Would be really really helpful if it would be possible!!! Let me know your thoughts!

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: Arduino language...

Fri Aug 03, 2012 8:47 pm

If you mean to use the arduino's IDE, then the answer is no.
But if you mean, can i program it in a arduino like language, than yes.
Example "DexBasic" bare metal:

Code: Select all

include 'DexBasic\DexBasic.inc'                    
                                                  
pinMode  GPIO16, OUTPUT                            
                                                  
LetsLoop:                                        
digitalWrite  GPIO16, HIGH                      
delayMicroseconds  1000000                      
digitalWrite  GPIO16, LOW                         
delayMicroseconds  1000000                        
goto  LetsLoop                                    
                                                 
align 4                                           
ProgramSize:                                       
ScreenBuffer:                                     
I have also seen similar code for running from linux.
Batteries not included, Some assembly required.

User avatar
exartemarte
Posts: 376
Joined: Sat Mar 03, 2012 3:51 pm
Location: Middle England
Contact: Website

Re: Arduino language...

Sun Aug 05, 2012 11:02 am

Justwondering321 wrote:Hey guys, would it be possible to use the arduino language on the pi to control the GPIO pins??? Would be really really helpful if it would be possible!!! Let me know your thoughts!
Yes.

As DexOS points out above you can't use the Arduino IDE, but that's no loss. The Arduino programming language, for practical purposes, is C with Arduino extensions for accessing I/O ports. The same C compiler (GCC) is available on the Pi - in Debian it's installed by default - and if you install Gordon's wiringPi that adds Arduino-type functions (digitalWrite(), digitalRead(), etc) for accessing the GPIO ports.

You will need to use makefiles - that's something that is hidden from you in the Arduino IDE - but if you start with Gordon's example programs and his makefiles you can modify the makefiles to suit your own programs. Once you get into it, it's a lot easier than it sounds.

You will also need an editor. I don't use Linux editors, by and large (see below), but there are several available. Geany seems to be quite popular; Nano is available from the command line and has prompts on-screen for the basic functions; Vi is available from the command line but gives you no clues whatsoever - not even how to get out of it.

My own preference, outlined in this post, is to access the Pi remotely using a Windows pc to edit the files, with a terminal window to compile and execute them on the Pi. I dare say that Linux afficionados will shudder in disgust, but it works for me.

brunialti
Posts: 17
Joined: Sat Jun 09, 2012 9:11 am

Re: Arduino language...

Tue Aug 07, 2012 8:50 am

Why not Processing on RasPi?
It should be also the easy way to let arduino/raspi to communicate each other.

Return to “Off topic discussion”