Arduino progress

  • by

I am slowly reaching the point where I can use the technical information about the Arduinos (and clones) to make progress beyond ‘mashups’ of previous and example code. This allows me to make progress that is far faster and more satisfying – my confidence that any particular decision will lead to the desired effect has increased dramatically, which is so much more satisfying. Getting acquainted with the sources of information for the Arduinos has also made porting functions from one to another much faster – I can predict whether the smaller version (Uno to Nano to Gemma) will be able to function satisfactorily – do they have enough pulse width modulation pins for a servo to run (or else put the load on the processor and use a soft-servo), are they capable of receiving I2C signals?


Pinout diagrams:

For the Arduino Uno:

Arduino Nano:

Adafruit Gemma:


I2C attachment:

No need to specify which pins I2C attaches to – there is only one possible pin for SDA (provides the datastream) and one for SCL (provides the clock ‘beat’ so the processor knows at what rate to listen). These pins seem to be specified by the controller, not surprising that there is only one possible pin for each, which in turn is not surprising as I2C can support many devices off one set of pins.

For my purposes for now, interpreting I2C is started by attaching the appropriate library and attaching a device to I2C (usually any number will do)


Servo attachment and more general attachment:

Most servos are driven from a high voltage pin, a ground pin and a pulse width modulation signal – the position of the servo is determined by the duty cycle. Attaching the servo on digital pin “D5” on the Arduino Nano requires


(the number on the board) and not

myServo.attach(11) //the physical pin number

and also not

 myServo.attach(1) //the first PWM pin) 

. For attachment to the analogue pins attach to


where y is the number on the board of the analogue pin.


Use of the serial:

Use the serial port wherever possible, and move to a board that does not have a serial port (i.e. the Adafruit Gemma) at the latest opportunity. Checking for errors without the serial port, especially errors you have not investigated before and know the rough causes of, is much trickier.

Current simplified code to allow movement of servo based upon laser distance measurement:

#include <Wire.h>
#include <SparkFun_VL6180X.h>
#include <PID_v1.h>
#define VL6180X_ADDRESS 0x29
//think this is to do with the setup of the sensor not the board? 
//But where do we define the position of the sensor
//suppose there are only one SDA SCL on the board so must be those?
int x;
#include <Servo.h>
#define SERVO1PIN 5
Servo myServo1;
VL6180xIdentification identification;
VL6180x sensor(VL6180X_ADDRESS);

void setup() {
x = 0;

void loop() {
x = sensor.getDistance();
x = constrain(x,17,50);
x = map(x,17,50,0,180);

Arduino Gemma in action – note a little more sluggish due to constant servo refresh required by the soft servo library:

Arduino Nano in action

Leave a Reply