G+_Lee Crocker Posted February 13, 2015 Share Posted February 13, 2015 To clarify something that wasn't pointed out on the show...The programming language there is C; nothing more, nothing less. In fact, under the hood, the Arduino IDE uses avr-gcc as its compiler and avrdude as its uploader, both of which you can use directly without the IDE if you choose. An Arduino "sketch" is nothing but a C program, except that they've already written the "main" function for you, that looks something like: int main(int ac, char *av[]) { arduino_standard_setup(); setup(); while (1) { loop(); } } You are expected to fill in the setup() and loop() functions. But if you don't want to use the Arduino IDE, you can do your own main() instead if you want. Likewise, the IDE links in its own libraries with things like digitalWrite(), which are written in terms of the Arduino hardware pins. If you use avr-gcc directly, you have to write in terms of the chip's registers, so turning on an LED might be more like: DDRB |= 0x20; PORTB |= 0x20; (Pin 13 on the Arduino board is connected to pin "PB5" of the Atmel chip.) Avr-gcc also allows you to write interrupt service routines and use in-line assembly. Finally, the IDE shows you how much memory is being used by your program. This too is available outside the IDE with the program avr-size. On my latest work project, it looks like this: avr-size -C --mcu=atmega164p testcode.elf AVR Memory Usage ---------------- Device: atmega164p Program: 9682 bytes (59.1% Full) (.text + .data + .bootloader) Data: 572 bytes (55.9% Full) (.data + .bss + .noinit) All in all, sticking with Arduino IDE is a great place to start. But realize that you are in fact learning C at the same time, and you can take your code with you when you outgrow it. Final note: A Radio Shack near me was having a big sale what with them going bankrupt and all, and I got an Uno and a Relay Shield for about $40. Thinking of making a sous vide rig with it. Link to comment Share on other sites More sharing options...
G+_Matthew Reardon Posted February 17, 2015 Share Posted February 17, 2015 So no objects? Just procedural? Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted February 17, 2015 Author Share Posted February 17, 2015 Object-oriented code is a matter of design. It can be done in C or assembly or any other language, whether the language is designed for it or not. Plus, for most of the tasks I've done with small embedded devices, object oriented design would be stupid. Link to comment Share on other sites More sharing options...
G+_Matthew Reardon Posted February 17, 2015 Share Posted February 17, 2015 Great..got lost on c# Sharp module with objects. Link to comment Share on other sites More sharing options...
G+_Lee Crocker Posted February 17, 2015 Author Share Posted February 17, 2015 Object-oriented design is great for many things--particularly GUIs. I'ts definitely something worth learning. But devices with two buttons and a few LEDs are usually better served with state-machine designs. Link to comment Share on other sites More sharing options...
Recommended Posts