WEEK 6 - Embedded Programming

Checklist:

  • Write a program for a microcontroller development board to interact (with local input &/or output devices) and communicate (with remote wired or wireless devices)

Connections Diagram

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.

Basic Concepts and Test Code

To solder the components onto the PCB, I used this quick guide to identify the components and their positions, ensuring that I soldered them in the correct orientation.


Test Code and Result

Test 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);
}

Result

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.


Download resources

Codes