Overview
This article describes how to create an Arduino sketch (program) using the GR-CITRUS board. The main tool used to create sketches, Renesas Web compiler, is compatible with Windows and Mac.
Preparation
You will need a GR-CITRUS board and a USB cable (micro B type).
Protocol
1. Login to the Web Compiler
Login to the Web compiler from the GADGET RENESAS top page.
Click the link shown in the image to the right to open the top page in a new tab.
Enter your MyRenesas account information and press the Sign In button.
2. Create a Project
Use the buttons shown below to create a new project. Skip this step if this is the first time you are logging in.
As shown in the following window, select GR-CITRUS_Sketch_xxx.zip (xxx indicates the version), assign any project name you like, and press the Create Project button.
3. Sketch Display
The Create Program window is displayed as follows. Double-click gr_sketch.cpp in the Explorer navigation bar on the left side of the window to display your program.
What you see displayed is the sketch (program) that will run GR-CITRUS.
4. Build the Sketch (Compile the Program and Create a Write File)
This window is where you will write programs. A sample program has already been completed for you that turns on the LED located on the GR-CITRUS board.
First click the Execute Build button in the right navigation section. The build is successful when the following message is displayed: “The compile was successful.”
Note: The first build after creating a project takes a little longer than normal, because all of the files are being compiled.
The results of the build are displayed as follows. If the build is successful, the following message is displayed: Make process completed. Click the Close button to close the window.
5. Download the Sketch (Save the File to be Written to the Computer)
When the build is successful, a citrus_sketch.bin file is created. Right-click on this file name to open the pull-down menu. Select Download to download the file to your computer.
6. Connect GR-CITRUS and Computer with USB Cable
Next, connect the GR-CITRUS board to your computer with the USB cable. After connecting the two, press the Reset button. The GR-CITRUS board will be recognized as a USB memory.
7. Write and Run the Sketch
Copy and paste the citrus_sketch.bin file you downloaded to your computer. After the sketch is written, the LED will turn on.
Make the Sample LED Flash Like a Firefly!
The following sample makes the GR-CITRUS LED flash softly like a firefly. Copy the sketch to the Web compiler and give it a try!
#include <arduino.h>
void setup(){
}
void loop(){
for(int i = 0; i < 256; i++){
analogWrite(PIN_LED0, i);
delay(5);
}
for(int i = 0; i < 256; i++){
analogWrite(PIN_LED0, 255 - i);
delay(5);
}
}