## For instruction on writing tutorials
## http://www.ros.org/wiki/WritingTutorials
####################################
##FILL ME IN
####################################
## for a custom note with links:
## note =
## for the canned note of "This tutorial assumes that you have completed the previous tutorials:" just add the links
## note.0=
## descriptive title for the tutorial
## title = Programming the Lizi robot micro-controller
## multi-line description to be displayed in search
## description = This tutorial explains how to re-upload the code to the Lizi robot micro-controller (Atduino DUE).
## the next tutorial description (optional)
## next =
## links to next tutorial (optional)
## next.0.link= [[lizi_robot/Tutorials/Lizi robot installation|Lizi robot installation]]
## next.1.link=
## what level user is this tutorial for
## level=  IntermediateCategory
## keywords = lizi micro-controller arduino
####################################
{{{#!wiki blue/solid
'''Note:''' This Tutorial is designed for use only with robots purchased before June 2014. The current packages are in [[ric|ric]]
}}}

<<IncludeCSTemplate(TutorialCSHeaderTemplate)>>

<<TableOfContents(4)>>

In order to upload new code to the micro-controller, the following commands should be executed locally on the computer which is installed on the Lizi that we want to program:

=== Install Java ===
{{{
$ sudo apt-get install gcc-avr avr-libc openjdk-6-jre
$ sudo update-alternatives --config java
}}}
=== Install the Arduino IDE ===
Install Arduino 1.5.6 or newer from (http://arduino.cc/en/main/software).

=== Configure the default PWM frequency ===
In your Arduino installation folder go to hardware/arduino/sam/variants/arduino_due_x/ and edit the variant.h:

Look for the line:

#define PWM_FREQUENCY 1000

And change it to:

#define PWM_FREQUENCY 20000

=== Get the Lizi sketch and libraries ===
Copy the content of the lizi_robot/lizi_arduino/Arduino folder into your Arduino sketchbook location (usually ~/Arduino).

=== Upload the sketch ===
Start the Arduino IDE and load the LiziDUE2 if you have the lizi2 (two motors version) or LiziDUE4 if you have the lizi4 (four motors version).

From Tools->Board select "Arduino Due (Programming Port)".

From Tools->Port select "/dev/ttyACM0 (Arduino Due (Programming Port))".

Click Upload.

{{{#!wiki blue/solid
'''Note:''' For future uploads only steps 1.4-1.5 are required.
}}}
{{{#!wiki red/solid
'''Warning:''' Editing code incorrectly may cause damage to elements of the robot.
}}}

## AUTOGENERATED DO NOT DELETE
## TutorialCategory
## FILL IN THE STACK TUTORIAL CATEGORY HERE