My contribution to the group involved researching the Atmega328P-AU, identifying its advantages, disadvantages, and key features. Additionally, I mapped out the programming pins and outlined the workflow from the software perspective.
To begin programming, it was necessary to determine which LEDs were connected to which pins of the Seeeduino. To achieve this, I created a diagram to help identify these pins and communication ports.
buttonPin
is assigned to analog pin A1.ledPin
is assigned to analog pin A0.buttonState
is a variable used to store the state of the button.pinMode(ledPin, OUTPUT);
sets pin A0 as an output, which will control an LED.pinMode(6, OUTPUT);
sets digital pin 6 as an output.pinMode(7, OUTPUT);
sets digital pin 7 as an output.pinMode(buttonPin, INPUT);
sets pin A1 as an input to read the button state.buttonState = digitalRead(buttonPin);
reads the current state of the button (either HIGH if pressed or LOW if not pressed).if (buttonState == HIGH)
checks if the button is pressed.digitalWrite(ledPin, HIGH);
turns on the LED connected to A0.digitalWrite(ledPin, LOW);
turns off the LED connected to A0.digitalWrite(6, HIGH);
and digitalWrite(7, HIGH);
turn on the LEDs connected to pins 6 and 7.delay(1000);
waits for 1 second.digitalWrite(6, LOW);
and digitalWrite(7, LOW);
turn off the LEDs connected to pins 6 and 7.delay(1000);
waits for another 1 second.First, you need to install the board. I obtained the necessary information from the Seeed Studio website. The initial step is to add a web address in the Arduino software preferences to install the XIAO SAMD21 board. After this, connect the board, select the appropriate COM port, and upload the code.
const int buttonPin = A1;
const int ledPin = A0;
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
delay(1000);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
delay(1000);
}
I programmed the LEDs connected to pins 6 and 7 to turn on and off every second, and the LED connected to pin A0 to turn on each time the push button is activated.
Code I used to test the board.
Code I used to test the board and record the results video.
Modified for making the paths thicker.
Modified for making the paths thicker.