how can Arduino save data to a file?
Arduino HEX file compile
Burning a Bootloader Using a Tinyusb device for Atmega IC's
Xloader for windows, flas the Arduino with a Hex file using a Windows GUI
VB 2010 USB port programing
Arduino is an "open-source" re-programmable printed circuit board developed in Italy for everyone.
Like the "World Wide Web" "Arduino" to some extent is free and to every extent open to anyone who is interested in learning how electronics and programming work together.
Truth be told, anyone can use Arduino, and anyone can learn how to use it with ease. Just like everything, learning Arduino will take some practice and may seem hard to understand at first, but once you take on one or two Simple tasks things will start to make sense and get easier. (Reading the odd tutorial like this can't hurt anything either).
So that's a small explenation of what Arduino is, but it really doesn't explain things. How does Arduino work and how do you use it?
Arduino is a printed circuit board (PCB) that has smarts, they all have an "AVR" Integrated circuit and most come with the Arduino library already installed on them, the Arduino Library is known as a "bootloader" . Next to that the PCB has a "Crystal", "TFID IC", a "USB interface", "capacitors", "resistors", and a few other components, they all work together making it possible for you to plug the PCB into your computer USB and load C++ onto it.
Arduino works with a number of programming languages to make a user interface, please see whatisacnc.com/arduino for more.
Arduino is very common place with the 3D printer, Firmware is needed to run the free 3d Printer A.K.A the "Rep-Rap", firmware is a fancy word for Arduino Sketch.
So you want to load your own sketch, how do you a program an AVR?
Arduino is great, unlike "Phidgets" (an alternative to Arduino) the Arduino can be programmed using the USB port and a pre-written User Interface, the interface has a collection of pre-written sketches you can load onto the Arduino for free, and all of them you can change in any way you choose.
Control anything you like with just the click of a mouse, you don't even have to type anything, just copy, past, compile, and load, two button clicks and you're programming anything from a servo to a tweetable garage door opener.
In simple terms the GUI is the screen you're using to view this text, it's the Windows, OSX, or Linux operating system you use, in simplest terms it's the interface between you and the computer code.
In the case of this web page the User Interface is the Browser, and in the case of Windows the interface is Explorer.
Behind all interfaces you'll find a database or file with the extension .INI or .XML, those files or database hold some pre-defined values, all you do with the GUI is make accessing that data simple to navigate and understand, the AVR is no different.
That's important to note because the Mico-Controller (in this case Arduino) works by calling "pre-defined values", the computer program you write, or the IDE you use accesses that information.
For example, if I write a program in C++ for Arduino that controls a servo motor, I'd probably tell Arduino that the command #2 turns the motor one way and the command #3 reverses it; the GUI would have a button or picture that when clicked sends a #2 or #3 to the USB port.
To make a GUI we can use a number of programming languages, each has its strong and weak points and some are only good for certain operating systems, no one language is the proper language.
The Arduino is programmed by calling the pin number you defined in the sketch (The C++ language stored on the Arduino), below are a few examples of programming languages that you can use to write a simple user interface.
Only a few languages are noted here, the ones on this page are the more frequently used, however the GUI (Graphical User Interface) can be one of or a combination of many other languages; any programming language that can communicate with a USB port will work.
Visual C# is a free IDE provided by Microsoft, and is probably the best way to program the Arduino, you will find lots of literature on the web for using this language and the language is more flexible making it possible to do much more with it.
PHP is a lanuguage used in Web-Development and is a Server-Side language, using PHP a person could interface with the Arduino by calling pins already specified on the Arduino, the Language on the Arduino is always C++ or HEX. The PHP and HTML is the GUI.
For some great tutorials and a very simple guide programming in PHP check out these websites:
PHP Class Index (A class is used to define options, use "php include" to use them)
Visual Basic is another way to interface with the Arduino, it looks a little more professional when used with Windows however it is a programming language restricted to the same operating system.
Visual Studio offers other compilers, including VB.NET, C, C#, C++ just to name a couple, and now the "Microsoft Code-Plex" is offering a free install for Visual Studio and Arduino. The install can be found at
The download location may change.
Python is also a very popular programming language and is cross platform, it's a great language to learn and is ver flexable, like C# it's a suggested programming language to use for development of the Arduino
Getting familiar with Arduino:
Below are a few really cool Arduino Projects, along with more details on how to use specific things with the Arduino, including that smart phone. Most of the "Sketches" below are usefull, or at the very least fun to try.
You can start with something complex or simple, however I sugges that you jump in with both feet. Don't be shy, all you're going to do is learn regardless of where you're at, if you start out too complicated and start over with something a little easier you'll still retain some of the information from the complex project.
Here is something interesting... The Arduino Clock
Attached is a simple sketch to use with a LCD screen and six buttons.
You can view or download the code by clicking on the image, it's open source so you can change it in any way you like. If you choose to Download the sketch, simply Highlight the text and past it into the Arduino GUI.
The "Sketch" is for the 1602 LCD Keypad Shield and Arduino. It works with the Arduino Duemilanove, UNO, MEGA2560, and the MEGA1280.
What is a sketch?
A sketch is a document written in C# for Arduino. The document is compiled by using the GUI (Graphical User Interface), and can be uploaded to the "AVR" Intergrated Circuit the same way.
Uploading information to an Intergrated Circuit like the AVR on the Arduino is known as "Flashing". Arduino has provided a great program for anyone new to programming and anyone without "ISP" installers. The tool allows you to Flash the device by inserting C# language.
Click on the image for a sketch that uses a "momentary button or switch" and the "8 relay Joy-To-The-World" sketch together.
The sketches used to acheive the objective:
Click on the image to see the result!
The nice thing about this sketch is that any sketch can be launched by tripping a sensor or by pressing a button.
Click on the image to download a free Arduino 8-Relay "Joy to the world" Sketch.
The Sketch switches 8 relays on and off as if playing "Joy to the world", simply use the Arduino GUI and past the contents of the text file into it, click on the "Compile" button, then "Upload".
That's it, if your relays are connected to the proper pins, in this case pin numbers:
"2 3 4 5 6 7 8 9"
you will hear the relays click on and off.
Have fun and be safe!
By clicking on the image to the right you can view or download a simple Servo Motor Sketch.
the sketch is written in C# and easy to understand. It is intended to be a simple example and will help with setting a motor speed.
Click on the image to the right to visit a website that describes how to use your smart phone with your Arduino of choice and a Android Smart Phone.
Android is an Open-Source Operating System for smart phones, it's owned by Google and is free for anyone to install and use unlike its competition. because anyone can use Android lost of people hack it and change the operating system to do crazy cool things with a Smart Phone and Arduino.
A christmas tree sketch, Automate a Christmas tree using this Sketch.
You can turn a tree into a robot, have lights turn on and off, switch on a servo or two and have the mouth and ears move, even connect it to the web with the help of the Twitter. Arduino is great fun for everyone.
Try it out and see what you can come up with, the code is pretty self explanitory.
With the Ethernet sheild for Arduino you can use Twitter to control things, or setup a web-server with the Arduino.
By clicking on the image to the right you can find out how to use Twitter with any Arduino.
By clicking on the image on the right you will find instructions for making a Tweetable Coffee Pot.
On your way into work and have some coffee to brew? Just tweet your Coffee maker and have it brew a pot of coffee.
The Atmel AVR:
Atmega 168 related links
Sketches and data:
http://www.instructables.com/id/ServDuino-Arduino-Webserver/step7/Programming/ web server programming samples
Some of the obove examples can also be found under examples in the free Arduino GUI, for more complicated ideas remember the importance of a flow-chart.
http://www.instructables.com/id/Tweet-a-Pot-Twitter-Enabled-Coffee-Pot/ Tweet a pot of coffee
So what is Arduino and how do you use it to control a Mill, 3D printer or a lathe?
Well, after some research I have discovered that the best driver board to use is dependent on the stepper motor you would like to drive, in my case I am using Nema size 17 motors, they are high torque motors requiring 2.5A and 12V. I will also be using the Atmega328 found on the Duemilanove, the older of the Arduino boards, being this is an older board you may have something a bit more recent like the Arduino 2560, don't worry it will work.
So here is the delema, how does Arduino read "G-code" from the computer? How do you write a GUI? Really how do I make this work for as little money as possible?
The goal: Have Arduino read G-code from a text file on the computer then send pulses to the driver boards, the driver boards (powered from an alternate source) drive the steppers as the signal is sent to them. So how do we do that?
Well here is the solution: To start you will need to connect the three driver boards to the Arduino Board, you can use the pin-out below or use your own, really you only need four wires to the Arduino for each driver board attached, just take note of the I/O's used on the micro-controller.
Next you will need some software, like a sketch for the Arduino so it knows what to do, and you will need some sort of G-code reader, maybe something written in "C" language or "Visual Basic", part of the "Visual Studio" family free from Microsoft, (yea I know Microsoft gives nothing away for free, but this is!!). For the software I would like to direct you to the following websites, both are part of the Rep-Rap movement and are open source, the VB script hasn't been compiled so it's good for a person wanting to edit the software using Microsoft Visual Studio, a free Basic Programming suite for anyone interested in learning how to program. You can download VB 2010, Visual C, and others, what is great, the software works like "Microsoft Frontpage" did for web developers.
The websites are:
You will want to delve into the world of HEX, as you will find out by visiting the websites noted. I will provide some direction as this progresses, note, this is not a big deal.
So what stuff do you need? Here is a BOM (Bill Of Material), you can change things to suit your needs and dreams, but to keep things simple here is a small list:
1 An Arduino Micro Controller. (Anything works)
2 Three Driver boards. (Must be capable of handling the Amperage and Voltage needed from the Stepper Motor.
3 Nema-17 motors. (You can choose others, just make sure the Driver can handle the Motor)
4 Power supply. (Must provide the proper Voltage and be capable of supplying the correct Amperage) Some people will use one power supply for each component.
So how do you connect the driver you purchased to the Arduino Micro controller? Lets start with the Pin's on the Arduino, these are usually refered to as I/O's short for (In, Out's). If you take on other projects later using Arduino you will see why they are called I/O's.
Below you will find the I/O configuration to connect the stepper drivers to the Arduino for control of a 3D printer.
Digital I/O #0 = RX
Digital I/O #1 TX
Digital I/O #2 X step
Digital I/O #3 X dir
Digital I/O #4 X min
Digital I/O #5 fan
Digital I/O #6 heater
Digital I/O #7 Y dir
Digital I/O #8 Y min
Digital I/O #9 X max
Digital I/O #10 Y step
Digital I/O #11 extruder motor pwm
Digital I/O #12 extruder motor dir
Digital I/O #13 Y max
Analogue I/O #0 (D14) thermistor
Analogue I/O #1 (D15) valve pwm
Analogue I/O #2 (D16) valve dir/Z max
Analogue I/O #3 (D17) Z min
Analogue I/O #4 (D18) Z dir
Analogue I/O #5 (D19) Z step
Original information found on the Rep-Rap website Using Arduino, Sanguino to run the 3D printer.
We will also require three programs to make everything work properly.
To start we need the firmware "Teacup" Firmware and "Merlin" Firmware is the more common and they support the "Arduino" family, it will also work with the "Sanguino", these are powered using Atmega Integrated Ciruits.
The next peice of software is the Arduino GUI, short for (Gaphical User Interface) it is the IDE, short for (Integrated Design Environment) for the Arduino Board. it makes it so you can load the edited firmware onto the Atmega chip.
From that you need to install and run a program that takes the 3D image and converts it to G code, there are a number of programs available, for this example I chose Replicator-G, although two are suggested on the Teacup Firmware page of the Rep-Rap Wiki.
Next: Setting up the drivers, wiring things.
Lets start with the stepper motor, and how you can find out what wires go together, the difference between them, and the best places to buy them.
To Start a stepper motor works by charging coils, the stator consists of a number of coils, the armature is a powerful rare earth magnet, when the coil gets charged the armature is attracted to the coil on the stator.
So how do you wire a stepper motor? Most steppers will have 4 - 8 wires, I know a bit crazy but really they are simple to understand, just spend a few seconds looking at the data sheet provided from the manufacturer of your particular motor. Most are Unipolar, but you can find Bipolar and Hybrid stepper motors, you can't go wrong with a Hybrid motor and the most common are Unipolar, however a Bipolar can be wired like a Unipolar motor, you just don't connect the "center taps" these steppers will have 6 or more wires. Unipolar motors only have 4.
So where do you buy them? This website has them for sale, and many people sell them online. The size 17 motor is the most common for the DIY project offering good torque and high resolution.