Average rainfall 2001-2016, global tropics

Map: Average rainfall 2001-2016, global tropics

ide: Micropython rainbow blink

Introduction

MicroPython is a tiny open source Python dialect that runs on microcontrollers - like the Adafruit Feather nRF52840 microcontroller that I use for developing xSpectre’s handheld spectrometer.

Micropython pin labels for Adafruit nRF52480 Express

The naming of the pins, both for Arduino IDE and CircuitPython, for the Adafruit nRF52480 Express board is here.

Neopixel blinking

The python script below loops a rainbow colored sequence for the Adafruit Neopixel Red-Green-Blue light on the Adafruit nRF52480 Express board.

"""
Rainbow Blink example for NeoPixel LED Arduino Feather Express.
Includes QT Py and various Trinkeys.
Requires two libraries from the Adafruit CircuitPython Library Bundle.
Download the bundle from circuitpython.org/libraries and copy the
following files to your CIRCUITPY/lib folder:
* neopixel.mpy
* adafruit_pixelbuf.mpy
Once the libraries are copied, save this file as code.py to your CIRCUITPY
drive to run it.
"""
import time
import board
import neopixel

rgbPixel = neopixel.NeoPixel(board.NEOPIXEL, 8, brightness=0.1)

loopnr = 0

outerloopnr = -1

RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)

while True:

    print(loopnr)
    # Step rgbpixel values blue - green - yellow - red - purple - blue
    if loopnr % 6 == 0:
        red = 0
        green = 0
        blue = 100
        rgbPixel.fill(BLUE)
        outerloopnr += 1
    elif (loopnr-outerloopnr*6) % 5 == 0:
        red = 0
        green = 100
        blue = 0
        rgbPixel.fill(CYAN)
    elif (loopnr-outerloopnr*6) % 4 == 0:
        red = 100
        green = 100
        blue = 0
        rgbPixel.fill(GREEN)
    elif (loopnr-outerloopnr*6) % 3 == 0:
        red = 100
        green = 0
        blue = 0
        rgbPixel.fill(YELLOW)
    elif (loopnr-outerloopnr*6) % 2 == 0:
        red = 100
        green = 0
        blue = 0
        rgbPixel.fill(RED)
    else:  
        red = 100
        green = 0
        blue = 100
        rgbPixel.fill(PURPLE)

    rgbPixel.show()
    time.sleep(0.5)
    loopnr += 1