Let's Make a Gadget with the Renesas GR-COTTON Board!

Let’s have a bit of fun creating unique gadgets with the GR-COTTON board and web compiler provided by the Gadget Renesas Project. The GR-COTTON board comes mounted with a very small microcontroller (MCU). By programming this IC, you can make lights flash, emit various noises and trigger objects to move!

Sketch Reference

This reference describes libraries for writing programs for the GR-COTTON board and HTTP API for controlling the web compiler.

About Arduino-like Sketches

The GR-COTTON board is compatible with Arduino, with the libraries being nearly the same. The only key difference is, in Arduino, programs are called "sketches". For simplicity, we call a programs "sketches" for GR-COTTON as well.

Here's a little explanation about sketches. Take a look at the sample sketch below. This is a simple sketch that turns on a red LED on the GR-COTTON board.

#include <Arduino.h>
void setup(){
    pinMode(22, OUTPUT);
void loop(){
    digitalWrite(22, HIGH);
    digitalWrite(22, LOW);

Arduino requires a unique description, setup() and loop(), to be included in the sketch. The setup() function is called only once after reset or power-on. Then, the loop() function is executed repeatedly. For example, the sketch to the right turns the LED on and off the using pinMode(), digitalWrite(), and delay() functions. The pinMode() in the setup() defines which pin to use for driving the LED. Then, the digitalWrite() turns the LED on and off. The delay() defines on and off time. When using the GR-COTTON board, always describe #include <RLduino78.h>, the library that includes all these Arduino compatible functions, in the first line.

The best thing about Arduino is its plentiful choice of libraries. These libraries make it easy to not only turn on LEDs, but also emit noises, run motors and connect to networks. Check out the lineup in the LIBRARY tab from the menu above.

About the Pin Layout

The image below describes the pin layout for the GR-COTTON board. There are many cases where you will use the library with a pin number. For example, the following description:

digitalWrite(2, LOW);

This means to set pin2 to LOW. And, from A0 to A7 can be used to read an analog value. For example, the following description:




March 30, 2018: Updated Serial and Ethernet. Added SoftwareSerial.


You can create a gadget easily with the libraries. Most of the functions that you want to use are here, such as ADC, timer, PWM, sound generation, SPI communication, USB virtual COM port, USB host, real-time clock, memory card, and Ethernet.

Basic Library

This is basic output of the digital signal, calculation and interrupt. You can use the basic library without additional description, #include and instance generation. For example, the following description:

#include <Arduino.h>
void setup() 

The code above can be described in the setup and loop function without additional code.

Standard Library

This library is for applied operation, motor control, SPI communication, memory operation, etc. You can use it with additional description. For example, the following description for a servo motor.

#include <Arduino.h>
#include <servo.h> 
Servo servo0;
void setup() 
  servo0.write(90);  // set servo to mid-point

This means to attach a servo motor to pin9 and set the angle to 90.

Web Compiler Control API

This API enables the user to control a project from the web compiler using HTTP communications. For example, easily create a program for a smartphone application.

The general flow in using the API is as follows: Get the project or file information in the web compiler, rewrite the specified file, then download the results of the build.

An API key is required to execute this API.

Open the settings page for details concerning the API key.

An error (null value) is returned if an API is executed while another API is already in progress.


Feel free to go to the Renesas Engineering Community with questions, problems or comments. Other users, both veterans and newbies, are there to help!