Skip to content

8. Embedded programming

Hero video

Group assignment

In his week’s group assignment, we’ve compared the performance and development workflows for other architectures.

Read datasheet of SAMD11C

SAMD11C is one of the main microcontroller unit (MCU) we used to build our lab. Atmel provides nearly 1000 pages datasheet to describe it.

Interested information for me

USB Interface The SAMD11 series has integrated USB interface. I can programming it directly without a programmer once I burn the relavent bootloader. The other thing is my final project will use a USB steering wheel to control my RC car. A integrated USB interface helps me to do this without a USB shield.

Program with SAMD11C

  1. Upload Arduino Booloader into the SAMD11C using DAP-Link. Details

  2. Upload the testing program to the board with Arduino IDE.

  3. Test the program by pressing the button and observe the LED pattern changes

void setup() {
  // set the pin modes
  pinMode(A4, OUTPUT);
  pinMode(A2, INPUT);
}

void loop() {
  // if button being pressed, blink the LED
  if (!digitalRead(A2))
  {
    analogWrite(A4, 256);
    delay(100);
    analogWrite(A4, 0);
    delay(100);
  }
  // if button not pressed, fade the LED
  else
  {
    for (int i = 0; i < 256; i++) {
      analogWrite(A4, i);
      delay(1);
    }
    for (int i = 256; i > 0; i--) {
      analogWrite(A4, i);
      delay(1);
    }
  }
}

Explanation: In the loop() function, the program will keep detecting the analog pin A2’s value, which is managed by the button. When button was being pressed, the LED will blink with 100ms interval. If the button was not pressed, the LED will fading from 0 to 256.

Referencecs

Atmel-42363-SAM-D11_Datasheet.pdf


Last update: June 29, 2022