Index

Introduction

During my Fab Academy I worked with the new ATtiny, the ATtiny412, ATtiny1614 and the ATtiny3216. But as a novelty this year there were also the new ARM microcontrollers with JTAG such as the SAMD11.

For this I want to document on this page, the process of creating the programmer, as well as the SAMDino board that is similar to the Adrianino where you can connect different sensors or actuators and go testing to continue working on the Hello World project.

To carry out the following project and the documentation I have consulted the documentation of Quentin Bolsee and Florent Lemaire, as well as the advice of the instructor Nicolas De Coster. Thank you. 🤗

Features

  • Via USB you can directly program and read data from a sensor.
  • It contains a voltage regulator to power the board with a power supply (9V battery).
  • It has another 9V power connection to for example power a DC motor driver.
  • Then there are 4 outputs or inputs with VCC and GND on each side to be able to connect different inputs or outputs.
  • On the left there is an I2C connection to connect an LCD, OLED or a sensor that uses this communication. Working in progress. Still not working.
  • There is an LED and an integrated button, which will help us to test that the microcontroller works with a simple program.
  • Possibility of connection with the Adrianino input and output modules.

Datasheet

SAM D11C 14A

A new generation of Atmel microcontrollers with SAMDs. A low-power, high-performance ARM® Cortex®-M0 + based flash microcontroller and with a full-speed USB device.

  • 14 pin package.
  • Internal and external clock options with 48MHDigital Frequency Locked Loop (DFLL48M) and 48MHto 96MHFractional.
  • 16 KB Flash Memory.
  • 256 B EEPROM.
  • 4 KB SRAM.
  • Maximum voltage: 3.63 V; minimum voltage: 1.62 V.

After looking at the basic features, you will find the pinning of the microcontroller. More information in this link.

  • VDD: Supply voltage.
  • GND: Ground.
  • Digital pins: PA02, PA04, PA05, PA08, PA09, PA14, PA15, PA31.
  • Analog pins: PA02, PA04, PA05, PA14, PA15.
  • USB pins: PA24, PA25.

All I/O pins can be configured with internal pull up or pull down resistance.

Within the communications section there are different types and their pins are different. It is clear that the different communication protocols cannot all be used at the same time, because they have pins in common.

  • USART - Universal Synchronous and Asynchronous Receiver and Transmitter: It has the RX (PA31 or PA05) and the TX (PA30 or PA04).
  • SPI - Serial Peripheral Interface: It has only MOSI (PA04 or PA08), MISO (PA14 or PA30), SCK (PA09), SS (PA15) .
  • TWI - Two Wire Interface (I2C): It has SDA (PA14) and SCL (PA15).

Another important thing that the datasheet is telling us is that you have to keep in mind which kind of input component you are using, digital or analog: for instance, if you are using a temperature sensor (analog component) you have to connect it to an ACD (analog to digital converter) port otherwise the microcontroller isn't able to transform the information that is receiving from the sensor to a digital data.

SAMD11C Free Dap Programmer.

To work with this type of microcontrollers we need a programmer with JTAG. For this we can use the Atmel-ICE or the Particle. But the ideal is to create a Free Dap programmer using a SAMD11C.

Following Neil's documentation on the Embedded Programming class we will find two types of programmers, the hello.CMSIS-DAP.10.D11C and the hello.CMSIS-DAP.4.D11C. In my case I will use the latter together with the hello.SWD.10-4 converter.

Here you can see the boards already milled. IMPORTANT: remember to remove the excess copper around the USB, you could produce a short circuit. The other image with the BOM prepared.

Once all the components have been soldered, I have created a 3D case to make a better connection of the USB and I have also painted the red color for VCC and the white color for GND on the 1.27 mm SMD connectors. So when connecting flat cables there is no confusion.

Programming

Create a SAMD11C Free Dap Programmer. (Windows)

As I mentioned in the previous step, one of the advantages of this microcontroller is that we can turn it into a programmer. For this we need Atmel-ICE or Particle programmer. In my case I use the Particle.

We will connect the flat cables in the following way, from the Particle to the 10-4 converter, then with the 4-wire flat cable (in my case, 6-wire) to the future programmer.

IMPORTANT: We will connect the Particle or the programmer to the computer and our Free Dap Programmer to an external power supply (that is not the same computer).

  • 2. Then on the Fab Academy page (Embedded Programming) we will find the Free Dap bootloader that we will also download.

  • 3. Open terminal. We execute inside the EDBG folder edbg-b74-WINDOWS-7029fc4.exe -bpv -t samd11 -f free_dap_d11c_mini.bin The LED of our programmer should light up and appear on our screen like the following capture.

With this programming we get a programmer, now we can program other SAMD11C and have our own programmer or for the Fab Lab. This would be the connection, remember to feed the programmer to the computer and the future programmer to an external power source. Then we repeat the previous steps and program it.

SAM11C with Arduino

Once we have the SAMD11C as a Free Dap programmer, we can change the bootloader so that we can program the SAMD11C through the Arduino IDE. For this we will follow the following steps. You can find more information on the Mattairtech Git Hub.

  • 1. We will download the sam_ba_Generic_D11C14A bootloader.
  • 2. Open terminal. We execute inside the EDBG folder edbg-b74-WINDOWS-7029fc4.exe -bpv -e -t samd11 -f sam_ba_Generic_D11C14A_SAMD11C14A.bin Appear on our screen like the following capture.

  • 3. We open the Arduino program.
  • 4. In Preferences, we will add the URL of the additional cards that you can find here. We need the MattairTech LLC.

  • 5. The next step is to download Generic SAMD11C in the boards manager.

  • 6. We configure the Arduino IDE for the SAMD11C. The SAMD11C will appear in the COM port, in my case in COM 8.

  • 7. Now load the Blink program so that the LED on pin 14 blinks. When we upload it, all this information appears in the notifications section.

In this short video you can see the operation of a Blink on pin PA14 (14 in Arduino) where the LED is integrated. 😍

BOM and Schematic for SAMDino

This is the schematic where you can see all the components.

Samdino

Where to buy? Amount Price Total price
Proto Board FR1 Digikey 1/4 board 1,24 €/unit 0,31 €
SAMD11C 14A Digikey 1 1,01 €/unit 1,01 €
1uF capacitor 50V Digikey 2 0,18 €/unit 0,36 €
4,99kΩ resistor Digikey 2 0,09 €/unit 0,18 €
499 Ω resistor Digikey 1 0,09 €/unit 0,09 €
IC Regulator 5V 1A SOT223 Digikey 1 0,43 €/unit 0,43 €
IC Regulator 3.3V 100MA SOT23-3 Digikey 1 0,84 €/unit 0,84 €
1kΩ resistor Digikey 1 0,09 €/unit 0,09 €
10kΩ resistor Digikey 1 0,62 €/unit 0,62 €
LED Digikey 1 0,35 €/unit 0,35 €
Button Digikey 1 1,00 €/unit 1,00 €
Female 1 row horizontal header Digikey 14 0,15 €/unit 2,10 €
Connector Header SMD 4POS 1.27mm Digikey 1 0,39 €/unit 0,39 €
Total cost 7,77 €

Board design

Here you can download the Eagle files and the PNG's. Here is a sample of the PNG's, traces and cutting lines.

Inputs

Button

The button is the simplest element of the inputs. It is an open or closed contact that when we press it changes its state to closed or open.

  • Connection and schematic
  • In this case, the button is integrated on the board, on the PA04 pin (Arduino pin 4) and the LED on the PA02 pin (Arduino pin 2).

  • Programming
  • Here you will find the programming to use the button. Here you can find the Arduino file to download.

    - Arduino Hello Button

    //Fab Academy 2020 - Fab Lab León
    //Button + LED                           
    //SAMDino
    //SAMD11C
    //
    //Original code:Neil Gershenfeld 12/8/19
    // This work may be reproduced, modified, distributed,
    // performed, and displayed for any purpose, but must
    // acknowledge this project. Copyright is retained and
    // must be preserved. The work is provided as is; no
    // warranty is provided, and users accept all liability.
    //
    
    
    const int ledPin1 = 2;//first light
    const int buttonPin = 4;// button pin
    int buttonState = 0;//initial state of the button
    int i = 0; //variable intensity led
    
    void setup() { //declaration of inputs and outputs
      pinMode(ledPin1, OUTPUT);
      pinMode(buttonPin, INPUT);
    }
    void loop() {
      buttonState = digitalRead(buttonPin);// we read the state of the button
      if (buttonState == HIGH) { //if we press the button
      digitalWrite(ledPin1, HIGH);
      delay(500);                       
      digitalWrite(ledPin1, LOW);    
      delay(500);
      digitalWrite(ledPin1, HIGH);
      delay(500);                       
      digitalWrite(ledPin1, LOW);    
      delay(500);
      digitalWrite(ledPin1, HIGH);
      delay(2000);                        
      digitalWrite(ledPin1, LOW);    
      delay(1000);
      
    }
      else {  //if we don't press the button
      digitalWrite(ledPin1, LOW);
      }
    }

    Pyroelectric

    A passive infrared sensor (or PIR sensor) is an electronic sensor that measures infrared (IR) light radiated from objects in its field of view. They are mainly used in PIR-based motion detectors.

  • Connection and schematic
  • In this case we only need three cables; one for VCC to 5V, another for GND and another for the sensor output that in our case we will connect it to pin PA05 (5 in Arduino). I also use the LED that is on PA02 (Arduino pin 2).

  • Programming
  • Here you will find the programming to use a digital sensor such as the PIR. Here you can find the Arduino and Processing files to download.

    - Arduino Hello PIR

    - Processing Hello PIR

    //Fab Academy 2020 - Fab Lab León
    //PIR sensor                            
    //SAMDino
    //SAMD11C
    
    //Original code by Luis Llamas.
    
    const int LEDPin = 2;        // for LED
    const int PIRPin = 5;         // for PIR sensor
     
    int pirState = LOW;           // start there is no movement
    int val = 0;                  // pin status
     
    void setup() 
    {
       pinMode(LEDPin, OUTPUT); 
       pinMode(PIRPin, INPUT);
       Serial.begin(115200);
    }
     
    void loop()
    {
       val = digitalRead(PIRPin);
       if (val == HIGH)   //if activated
       { 
          digitalWrite(LEDPin, HIGH);  //LED ON
          if (pirState == LOW)  
          {
            Serial.println("1");
            pirState = HIGH;
          }
       } 
       else   //is not activated
       {
          digitalWrite(LEDPin, LOW); // LED OFF
          if (pirState == HIGH)  //si
          {
            Serial.println("0");
            pirState = LOW;
          }
       }
    }

    Doppler radar

    The RCWL-0516 is a Dopler Microwave Radar Sensor.It is an alternative to traditional PIR infrared motion detectors. Faced with these, it has certain differences, which will be an advantage or disadvantage depending on the needs of our project.

    First of all, PIR sensors require the moving object to have a temperature difference from the environment. For this reason, they are able to detect people, but not moving objects. In contrast, the RCWL-0516 detects any object that is moving, regardless of its temperature. On the other hand, PIR sensors have sensitivity problems when the ambient temperature is high. The RCWL-0516, on the other hand, does not have this problem and works correctly between -20ºC to 80ºC. In terms of detection range, the RCWL-0516 has a greater range than PIR sensors, being able to easily reach 5-7 meters of range.

    Finally, the RCWL-0516 is omnidirectional, that is, it detects movement in 360º. This is a difference from PIR sensors, which have a certain "angle of view". There are even versions of PIR with a narrow beam, for example to control windows or doors.

  • Connection and schematic
  • In this case we only need three cables; one for VCC, another for GND and another for the sensor output that in our case we will connect it to pin PA04 (4 in Arduino). IMPORTANT: connect the VCC to 5V.

  • Programming
  • Here you will find the programming to use a digital sensor such as the PIR. Here you can find the Arduino and Processing files to download.

    - Arduino Hello Radar

    - Processing Hello Radar

    //Fab Academy 2020 - Fab Lab León
    //Doppler radar                            
    //SAMDino
    //SAMD11C
    
    
    const int RadarPin = 4; // digital input pin to hook the sensor to
    int value = 6; // variable to store the value coming from the sensor
    void setup()
    {
      Serial.begin(115200); // initialize serial communications
      pinMode(RadarPin, INPUT); //digital input pin
    }
     
    void loop()
    {
      int value= digitalRead(RadarPin); // read the value from the sensor (0 or 1)
      Serial.println(value);  // print value to Serial Monitor
    }

    Ultrasonic sensor

    The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. It comes complete with ultrasonic transmitter and receiver modules.

  • Connection and schematic
  • In this case we only need four cables; one for VCC to 5V, one for GND, another cable for the Trigger (PA05, Arduino pin 5) and another for the Echo (PA04, Arduino pin 4).

  • Programming
  • Here you will find the programming to use a digital sensor such as the Ultrasonic sensor. Here you can find the Arduino and Processing files to download.

    - Arduino Hello Ultrasonic sensor

    - Processing Hello Ultrasonic sensor

    //Fab Academy 2020 - Fab Lab León
    //Ultrasonic sensor
    //SAMDino
    //SAMD11C
    
    
    
    const int EchoPin = 4;
    const int TriggerPin = 5;
     
    void setup() {
       Serial.begin(115200);
       pinMode(TriggerPin, OUTPUT);
       pinMode(EchoPin, INPUT);
    }
     
    void loop() {
       int cm = ping(TriggerPin, EchoPin);
      Serial.print("");
       Serial.println(cm);
       delay(1000);
    }
     
    int ping(int TriggerPin, int EchoPin) {
       long duration, distanceCm;
       
       digitalWrite(TriggerPin, LOW);  //to generate a clean pulse we set LOW 4us
       delayMicroseconds(4);
       digitalWrite(TriggerPin, HIGH);  //we generate Trigger (trigger) of 10us
       delayMicroseconds(10);
       digitalWrite(TriggerPin, LOW);
       
       duration = pulseIn(EchoPin, HIGH);  //we measure the time between pulses, in microseconds
       
       distanceCm = duration * 10 / 292/ 2;   //we convert distance, in cm
       return distanceCm;
    }

    Hall effect

    The Hall effect sensor or simply Hall sensor or Hall probe uses the Hall effect to measure magnetic fields or currents or to determine the position in which it is.

  • Connection and schematic
  • In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the hall effect sensor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the ATtiny1614 PA4 (Arduino pin 0).

    Here you can find the design in Eagle and the PNG's to create the board.

    - Hall effect Schematic + Board

    - Hall effect traces

  • Programming
  • Here you will find the programming to use an analog sensor such as the Hall effect sensor. Here you can find the Arduino and Processing files to download.

    - Arduino Hello Hall effect sensor

    - Processing Hello Hall effect sensor

    //Fab Academy 2020 - Fab Lab León
    //Hall Effect
    //SAMDino
    //SAMD11C
    
    int sensorPin = 4;    // analog input pin to hook the sensor to
    int sensorValue = 0;  // variable to store the value coming from the sensor
     
    void setup() {
      Serial.begin(115200); // initialize serial communications
    }
     
    void loop() {
      sensorValue = analogRead(sensorPin); // read the value from the sensor
      sensorValue = map(sensorValue, 290, 300, 0, 1024);
      Serial.println(sensorValue); // print value to Serial Monitor
      //mySerial.println("x"); // print value "x" to Serial Monitor
      delay(500); // short delay so we can actually see the numbers
    }

    Temperature. NTC.

    The NTC sensor is a type of resistance whose value varies as a function of temperature in a more pronounced way than a common resistance. Its operation is based on the variation of the resistivity that a semiconductor presents with temperature.

  • Connection and schematic
  • In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the NTC sensor, a 10K resistor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the SAMD11C PA04 (Arduino pin 4).

    Here you can find the design in Eagle and the PNG's to create the board.

    - NTC Schematic + Board

    - NTC traces

  • Programming
  • Here you will find the programming to use an analog sensor such as the NTC sensor. Here you can find the Arduino and Processing files to download.

    - Arduino Hello NTC Temperature sensor

    - Processing Hello NTC Temperature sensor

    //Fab Academy 2020 - Fab Lab León
    //NTC sensor
    //SAMDino
    //SAMD11C
    int sensorPin = 4;    // analog input pin to hook the sensor to
    int sensorValue = 0;  // variable to store the value coming from the sensor
     
    void setup() {
      Serial.begin(115200); // initialize serial communications
    }
     
    void loop() {
      sensorValue = analogRead(sensorPin); // read the value from the sensor
      sensorValue = map(sensorValue, 0, 85, 0, 40);
      Serial.println(sensorValue); // print value to Serial Monitor
      //mySerial.println("x"); // print value "x" to Serial Monitor
      delay(500); // short delay so we can actually see the numbers
    }

    Phototransistor. Visible.

    The Phototransistor sensor is a three-layer semiconductor device which has a light-sensitive base region. The base senses the light and converts it into the current which flows between the collector and the emitter region.

  • Connection and schematic
  • In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Phototransistor sensor, a 10K resistor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the SAMD11C PA04 (Arduino pin 4).

    Here you can find the design in Eagle and the PNG's to create the board.

    - Phototransistor Schematic + Board

    - Phototransistor traces

  • Programming
  • Here you will find the programming to use an analog sensor such as the Phototransistor sensor. Here you can find the Arduino and Processing files to download.

    - Arduino Hello Phototransistor sensor

    - Processing Hello Phototransistor sensor

    //Fab Academy 2020 - Fab Lab León
    //Phototransistor
    //SAMDino
    //SAMD11C
    int sensorPin = 4;    // analog input pin to hook the sensor to
    int sensorValue = 0;  // variable to store the value coming from the sensor
     
    void setup() {
      Serial.begin(115200); // initialize serial communications
    }
     
    void loop() {
      sensorValue = analogRead(sensorPin); // read the value from the sensor
      sensorValue = map(sensorValue, 25, 50, 0, 1024);
      Serial.println(sensorValue); // print value to Serial Monitor
      //mySerial.println("x"); // print value "x" to Serial Monitor
      delay(500); // short delay so we can actually see the numbers
    }

    Phototransistor. IR.

    The Phototransistor IR sensor is a three-layer semiconductor device which has a light-sensitive base region. The base senses the IR and converts it into the current which flows between the collector and the emitter region.

  • Connection and schematic
  • In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Phototransistor IR sensor, a 10K resistor, a IR LED, a 1K resistor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the SAMD11C PA04 (Arduino pin 4).

    Here you can find the design in Eagle and the PNG's to create the board.

    - Phototransistor IR Schematic + Board

    - Phototransistor IR traces

  • Programming
  • Here you will find the programming to use an analog sensor such as the Phototransistor sensor. Here you can find the Arduino and Processing files to download.

    - Arduino Hello Phototransistor IR sensor

    - Processing Hello Phototransistor IR sensor

    //Fab Academy 2020 - Fab Lab León
    //Phototransistor IR
    //SAMDino
    //SAMD11C
    int sensorPin = 4;    // analog input pin to hook the sensor to
    int sensorValue = 0;  // variable to store the value coming from the sensor
     
    void setup() {
      Serial.begin(115200); // initialize serial communications
    }
     
    void loop() {
      sensorValue = analogRead(sensorPin); // read the value from the sensor
      sensorValue = map(sensorValue, 40, 60, 0, 1024);
      Serial.println(sensorValue); // print value to Serial Monitor
      //mySerial.println("x"); // print value "x" to Serial Monitor
      delay(500); // short delay so we can actually see the numbers
    }

    Outputs

    RGB LED

    The RGB LED stands for Red, Blue and Green LEDs. RGB LED products combine these three colors to produce more than 16 million shades of light.

  • Connection and schematic
  • In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the RGB LED, two 1K resistors (for red and green color), a 499 resistor (for blue color) and with the flat connectors where there is no room for mistakes when connecting it. I use the digitals ouputs of the SAMDino PA04 (Arduino pin 4), PA05 (Arduino pin 5), PA08 (Arduino pin 8).

    Here you can find the design in Eagle and the PNG's to create the board.

    - RGB LED Schematic + Board

    - RGB LED traces

  • Programming
  • Here you will find the programming to use a RGB LED. Here you can find the Arduino file to download.

    - Arduino Hello RGB LED

    //Fab Academy 2020 - Fab Lab León
    //RGB LED
    //SAMDino
    //SAMD11C
      
      const byte COLOR_BLACK = 0b000;
      const byte COLOR_BLUE = 0b100;
      const byte COLOR_RED = 0b010;
      const byte COLOR_GREEN = 0b001;
      const byte COLOR_MAGENTA = 0b101;
      const byte COLOR_CYAN = 0b011;
      const byte COLOR_YELLOW = 0b110;
      const byte COLOR_WHITE = 0b111;
    
    
      const byte PIN_LED_R = 5;
      const byte PIN_LED_G = 8;
      const byte PIN_LED_B = 4;
    
    
      void setup() {
    
        pinMode(PIN_LED_R, OUTPUT);
        pinMode(PIN_LED_G, OUTPUT);
        pinMode(PIN_LED_B, OUTPUT);
        displayColor(COLOR_BLACK);
      }
    
    
      void loop() {
    
    
        displayColor(COLOR_RED);
        delay(1000);
    
        displayColor(COLOR_GREEN);
        delay(1000);
    
        displayColor(COLOR_BLUE);
        delay(1000);
    
        displayColor(COLOR_MAGENTA);
        delay(1000);
    
        displayColor(COLOR_CYAN);
        delay(1000);
    
        displayColor(COLOR_YELLOW);
        delay(1000);
    
        displayColor(COLOR_WHITE);
        delay(1000);
    
        displayColor(COLOR_BLACK);
        delay(1000);
        
      }
    
      void displayColor(byte color) {
    
        digitalWrite(PIN_LED_R, !bitRead(color, 0));
        digitalWrite(PIN_LED_G, !bitRead(color, 2));
        digitalWrite(PIN_LED_B, !bitRead(color, 1));
      }

    DC Motor

    To control a DC motor we will use an H bridge, such as the Allegro A4953. With this driver we can control all types of motors through PWM signals.

  • Connection and schematic
  • In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Allegro A4953 driver, a 1uF capacitor, a 10uF capacitor and with the flat connectors where there is no room for mistakes when connecting it. It includes two traces to feed with the 9V battery. I use two digital output of the SAMD11C PA04 (Arduino pin 4) and PA05 (Arduino pin 5).

    Here you can find the design in Eagle and the PNG's to create the board.

    - Motor Schematic + Board

    - Motor traces

  • Programming
  • Here you can find an example of a motor turning left, stopping, and turning right. Here you can find the Arduino file to download.

    - Arduino Hello Motor

    //Fab Academy 2020 - Fab Lab León
    //Motor
    //SAMDino
    //SAMD11C
           
    const int motor1Pin = 4;      // H-bridge pin 0 (in2) 
    const int motor2Pin = 5;      // H-bridge pin 1 (in1) 
    
    void setup() {
    
        // set H-bridge pins as outputs:
        pinMode(motor1Pin, OUTPUT);
        pinMode(motor2Pin, OUTPUT);
      }
    
    void loop() {
       // change the direction the motor spins by talking to the control pins
      // on the H-Bridge
    
        digitalWrite(motor1Pin, HIGH);    // Turn the motor in one direction
        digitalWrite(motor2Pin, LOW);
        
        delay(2000);                      // Wait two seconds
    
        digitalWrite(motor1Pin, LOW);     // Switch off the motor
        digitalWrite(motor2Pin, LOW);
    
        delay(3000);                      // Wait three seconds
    
        digitalWrite(motor1Pin, LOW);
        digitalWrite(motor2Pin, HIGH);    // Turn the motor in the other direction
     
    
        delay(2000);                      // Wait two seconds
    
        digitalWrite(motor1Pin, LOW);     // Switch off the motor
        digitalWrite(motor2Pin, LOW);
    
        delay(3000);                      // Wait three seconds
      }

    Servo motor

    A very common output is a servo. A servomotor is a device similar to a direct current motor that has the ability to be located in any position within its operating range, and remain stable in that position. In this case I use a 0 to 180 degree servo.

  • Connection and schematic
  • In this case we only need three cables; one for VCC, another for GND and another for the signal output that in our case we will connect it to pin PA04 (4 in Arduino). IMPORTANT: We must supply the servo with 5V. The circuit can be powered by a 9V battery.

  • Programming
  • Here you will find the programming to use a servo motor. Here you can find the Arduino file to download.

    - Arduino Servo

    //Fab Academy 2020 - Fab Lab León
    //Servo without library                           
    //SAMDino
    //SAMD11C
    
    
    int servo = 4;
    
    int angle;
    int pwm;
    
    void setup()
    {
     pinMode(servo, OUTPUT);
    }
    
    void loop ()
    {
     for (angle = 0; angle <= 140; angle += 5)  {
       servoPulse(servo, angle);  }
     for (angle = 140; angle >= 0; angle -= 5)  {
       servoPulse(servo, angle);  }
    }
     
    void servoPulse (int servo, int angle)
    {
     pwm = (angle*11) + 500;      // Convert angle to microseconds
     digitalWrite(servo, HIGH);
     delayMicroseconds(pwm);
     digitalWrite(servo, LOW);
     delay(50);                   // Refresh cycle of servo
    }

    Files

    Find below the files that I made for this project.