RAK WisBlock – Getting started using LEDs

As a starting exercise we’ll write a short code block to make the colored LEDs on the WisBlock blink back and forth. Not very sexy (or maybe it is?) but a great beginning exercise.

Prerequisites:

Making the LEDs blink:

Once you’ve completed this simple exercise you’ll have:

  • validated your ability to communicate with your WisBlock
  • upload your new firmware (sketch)
  • watch the WisBlock LEDs blink
  • monitor results using the Arduino Serial Monitor

After you’ve configured the Arduino IDE you can start writing your own code or just copy and paste if that is more your style.


// Copyright Coinpie.Academy (c) 2021 except as cited
// RAK4630 supply two LED

#include <Arduino.h>

// Green LED 
#define LED_GREEN 35
// Blue LED
#define LED_BLUE 36

#define MY_DELAY 100

void setup() {
  // put your setup code here, to run once:
  pinMode(LED_GREEN, OUTPUT);
  pinMode(LED_BLUE, OUTPUT);
  
  digitalWrite(LED_GREEN, LOW);
  digitalWrite(LED_BLUE, LOW);

  // BEGIN 
  // This code block is from @file LoRaWAN_OTAA_ABP.ino example
  // https://github.com/RAKWireless/WisBlock/blob/master/examples/RAK4630/communications/LoRa/LoRaWAN/LoRaWAN_OTAA_ABP/LoRaWAN_OTAA_ABP.ino

  // Initialize Serial for debug output
  // Code below is from 
  time_t timeout = millis();
  Serial.begin(115200);
  while (!Serial)
  {
    if ((millis() - timeout) < 5000)
    {
      delay(100);
    }
    else
    {
      break;
    }
  }
  // END -  @file LoRaWAN_OTAA_ABP.ino code block
  
  Serial.println("!========================================!");
  Serial.println("!      Welcome to CoinPie Academy!!!     !");
  Serial.println("! RAK4630 LoRaWan Setup Routine Complete !");
  Serial.println("!========================================!");
}

void loop() {
  // put your main code here, to run repeatedly:
  
  delay(MY_DELAY);  
  digitalWrite(LED_GREEN, HIGH);
  digitalWrite(LED_BLUE, LOW);
  delay(MY_DELAY);
  digitalWrite(LED_GREEN, LOW);
  digitalWrite(LED_BLUE, HIGH);
  Serial.println("Looping");
}

Items of note:

  • Green LED is pin 35
  • Blue LED is pin 36
  • Red LED is not accessible via the MRU

Below is the resulting output from the Serial Monitor:

18:24:05.616 -> =====================================
18:24:05.616 -> Welcome to CoinPie Academy!!!
18:24:05.616 -> RAK4630 LoRaWan Setup Routine Complete
18:24:05.616 -> 
18:24:05.616 -> BSP Library : 0.21.20
18:24:05.616 -> Bootloader  : s140 6.1.1
18:24:05.616 -> Serial No   : E8E13D56XXXXXXXX
18:24:05.616 -> 
18:24:05.762 -> Looping
18:24:05.948 -> Looping
18:24:06.136 -> Looping
18:24:06.320 -> Looping
18:24:06.553 -> Looping
...

Leave a comment

Your email address will not be published. Required fields are marked *

seventy two + = eighty