Why people like Arduino

I was just browsing a thread over at AVR Freaks and noticed this code snippet that sets up a UART

    //Set baud rate 
   UBRR0H = (unsigned char)( UBRRVAL>>8 );   //high byte 
   UBRR0L = (unsigned char) UBRRVAL;         //low byte 

   //Asynchronous normal speed 
   UCSR0A = (0<<U2X0); 

   //Enable Transmitter and Receiver and Interrupt on receive complete 
   UCSR0B = (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0); 

   //page 186 Set asynchronous mode,no parity, 1 stop bit, 8 bit size 
   UCSR0C= (0<<UMSEL00)| (0<<UMSEL01)|          //Async 
         (0<<UPM00)|(0<<UPM01)|               //Parity None 
         (0<<USBS0) |                     //Stop bits 1 
         (0<<UCSZ02)|(1<<UCSZ01)|(1<<UCSZ00);   //8 Bits 

   //enable interrupts 
   sei(); 
   }

Now this isn't as scary as it first looks and anyone used to working with embedded AVRs will feel quite at home with this code. But here's the Arduino equivalent

Serial.begin(BAUDRATE);

Ummm...is it any wonder that people who just want to make an interactive coffee table or even those more serious about getting into embedded processors are attracted to Arduino?


Rob

May the flame Wars.begin() :wink:

markbee

The arduino hides a lot of the detail you have to go through and lets you concentrate on the ideas you implement. That's why I like it, I've done all that lot years ago and it makes progress slow. I have even done in hex in the days before you could get assemblers let alone C compilers. That is writing down the mnemonic for each instruction and looking up the hex bits that implement it.

May the flame Wars.begin()

Not my intention and I hope it doesn't degrade to that.

I'm fairly well versed on both sides of the fence and am well aware of the pros and cons of either side. It's just that for some reason the above example drove home to me the difference as I think a newbie would see it. In fact it's probably even worse because just getting to the stage where you are writing the first example can be a struggle whereas I suspect most people who get an Arduino will be at the second example in no time (albeit without the constant for the baud rate :))

And then, as Mike says, there are experienced people who just want to get a simple project up and running.


Rob

The good thing with Arduino is, that you may become interested to dig deeper into the structure and behaviour of microcontrollers after doing some projects that work quick and easy.
You may begin to write libraries, shift some bits or anything that is one or two layers below the "Arduino-Easy-Layer." I think that is one often overloked "feature" of Arduino beside getting quick and easy a project running. And if you are not interested - so what. Don't block creativity by forcing people to learn everything from scratch.
I like to compare it to a car: you have to know how to drive it, but do you really have to know how the mechanics/ electronics work?
I personally began with 8051 and I would have been more than happy having Arduinos at that time.

markbee

And then, as Mike says, there are experienced people who just want to get a simple project up and running.

I tell people I know how to do all that, I'm just lazy and don't want to. :slight_smile:

It's a reason for liking and... disliking at the same time IMHO.

Still knowing very little about C-languages it's nice to write just a few lines and
get a project working. The choice between Serial.begin(Baudrate) and writing 20 lines
to accomplish the same is easy to make.

Looking at others peoples software for arduino I do encounter loads of commands/functions
poorly/not explained in arduinos reference though. Since there's not much explanation it's hard
to know what is possible and what's better.

Every now&then I also see people responding "What you basically need is this or that
(unexplained) function" to a question. Although I love the relative simplicity of Arduino, while coding that sometimes makes me wonder whether a single "unexplained" function may have done it better as... writing 20 lines of code as well.

I liken it in some ways to VB (Visual Basic). You sacrifice some raw power to get some refined power. Arduino is better however, in that you can still inline code in lower languages like C and Assembler, which you can't in things like VB and PERL. In my opinion, at any given time a project should be done in as HIGH level a language as possible, resorting to lower level coding ONLY where necessary. Reinventing the wheel fifty times a week isn't to be applauded.. especially if nothing but wheels ever gets invented!

You can rely on it being an inefficient platform- resources wasted right and left; much of the horsepower is sacrificed or hidden from your use; the majority of the language is just macros, with a search and replace engine as the "compiler".

You'll start a Barbeque if you mention it's useful, all of a sudden you are surrounded by nothing but weenies and flamers. My response to flamers and weenies is that unless you're making your own gates with a Bic lighter and a bucket of sand, whatever language you are programming in is no different or any "better" than any other, including VB/Arduino/TCL/What have you.. in fact, since this is the case, a very reasonable argument can be made that those mired in low-level coding are more of an impediment than a benefit. It's ALL just variations of the search-and-replace theme.

I don't discuss it often, as I really don't like "hating" on anybody- but understand how hostile the weenies can be.. I've been BBS'ing since the early 80's, and in thirty years I've been censored on two sites. One of those was AVRFreaks.. because I asked if there was value in learning this "Arduino" platform over WinAVR and the uberweenies decided to flame the "new guy" for not knowing any better. It went downhill from there. Even more disturbing were the chain of posts and unsolicited personal emails to my private email address, full of profanity from one of the ADMINS. AVR Freaks is what's WRONG with microcontroller and hobby development, no matter what the hardware is.. it's got nothing to do with AVR's, it just about the Freaks. That kind of attitude isn't found here, despite it being the same hardware.. and even many of the same people. Happily, there's little actual content at AVRfreaks that isn't mirrored someplace else these days, and it seems they are going offline for days at a time randomly now.. guess it just toxified itself to death.. If I would have had no other resource for a forum for AVR development, I would have walked away from the entire hobby (and possibly electronics in general) based upon the general level of Weenie Roast there. Hostility towards newcomers and those without a lot of experience doesn't fly here, happily. It's not the hardware, it's not the language, the IDE or the compiler. It's the people here. Pat yourselves on the back guys, there's nothing quite like Arduino.

Arduino, like Visual Basic (and other thing like it, such as PYTHON and PERL, TCL, etc) is however indespensible when it comes to making a fast prototype or if you need to cobble together a quick "one off" tool to get a job done. I can't tell you how many times during my working years I used VB as a front end for heavy lifting, and when it comes to building a simple database front end, I've never seen a tool that even came close. Hate on it all you want, in the real world, VB is one of the most useful and used tools on the market. In much the same way, Arduino makes it possible to quickly prototype with a modicum of experience, even if it's not the most efficient or "nerdy".

Arduino "wrappers" away much of the painful coding that would send most hobbyists looking for another hobby before they got their first projects running. A working project... I dare >> any << language zealot to find fault with a working design, no matter how it was done. Any whining you hear in the wings if your project works is just that- whining from people who couldn't actually DO the design, just complain...

I do think that maybe the Arduino compiler ought to make the compile stages more "accessible" or obvious to the user, to encourage them to "look under the hood". It's there and generated, but maybe when you compile in the IDE, it should pop a tab open with what the program compiles to in ANSI C. Assembler is just to dang painful to be useful in most cases. Stopping at C makes sense in the same way as having a carpenter stop being an expert at the lumber level, he doesn't need to know how to grow a tree to build a doorframe.

1 Like

For the most part, the Arduino framework is a 'good interface'.

It provides services to use on the basis of 'how would I like to tell my board to do something' rather than irrelevant implementation incantations.

Good programmers want to make life easy for themselves. Really good programmers want to make things easy for others.

Serial.begin, digitalread(), digitalwrite(), and analogread() are the reasons I love Arduino.

Building a complete environment for the 8051 (15+ years ago) was fun, at the time, but not practical today. Arduino reminded me of the fun of electronics. Got an idea? Twiddle some bits and go.

    //Set baud rate 
   UBRR0H = (unsigned char)( UBRRVAL>>8 );   //high byte 
   UBRR0L = (unsigned char) UBRRVAL;         //low byte 

   //Asynchronous normal speed 
   UCSR0A = (0<<U2X0); 

   //Enable Transmitter and Receiver and Interrupt on receive complete 
   UCSR0B = (1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0); 

   //page 186 Set asynchronous mode,no parity, 1 stop bit, 8 bit size 
   UCSR0C= (0<<UMSEL00)| (0<<UMSEL01)|          //Async 
         (0<<UPM00)|(0<<UPM01)|               //Parity None 
         (0<<USBS0) |                     //Stop bits 1 
         (0<<UCSZ02)|(1<<UCSZ01)|(1<<UCSZ00);   //8 Bits 

   //enable interrupts 
   sei(); 
   }

I wished that Serial.begin(baudrate) was overloaded with Serial.begin(baudrate, parity, databits, stopbits);

so I could state Serial.begin(5438,E,7,2); or something weird :wink:

I wished that Serial.begin(baudrate) was overloaded with ..............

The point is that it is not.

But even better the point is that if you need to do something weird then there is nothing stopping you from using the long code you posted.

Well, there was a thread on avrfreaks recently about Atmel's "Software Framework", and the differences between:

   gpio_clr_gpio_pin(LED0_GPIO);

and

   ioport_set_pin_low(LED0_GPIO);

Those are pretty ... unfriendly ... names compared to "digitalWrite(LED0, 0)"
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=110091&start=0&postdays=0&postorder=asc&highlight=framework