Skip to content

Instantly share code, notes, and snippets.

View SwitchScienceCode's full-sized avatar

Switch Science Code SwitchScienceCode

View GitHub Profile
# MicroPython sample program for M5Stack with AMG8833
# M5Stack
# http://www.m5stack.com/
# Panasonic Grid-EYE AMG8833
# https://industrial.panasonic.com/jp/products/sensors/built-in-sensors/grid-eye
# Usage
# Save this code as main.py then restart.
# Button A : Start drawing grid matrix of thermal data.
@SwitchScienceCode
SwitchScienceCode / gist:6a8786b09ef6179ccc38c6a67a9ad290
Last active February 28, 2018 00:06
Sample code for creating main.py with MicroPython's Paste-Mode.
str = '''
from m5stack import lcd
lcd.clear()
lcd.print('Hello World!')
'''
f = open('main.py', 'w')
f.write(str)
f.close()
@SwitchScienceCode
SwitchScienceCode / m5stack-amg8833-main.py
Last active November 24, 2021 12:28
Sample MicroPython code for M5Stack with AMG8833
# MicroPython sample program for M5Stack with AMG8833
"""
COPYRIGHT
This code is licensed under the MIT license.
<https://opensource.org/licenses/MIT>
Copyright (c) 2018 Switch Science, inc.
@SwitchScienceCode
SwitchScienceCode / list-hex-triplet-colors.py
Last active March 19, 2018 05:41
generate a list of hex triplet color code
#coding: utf-8
"""
COPYRIGHT
This code is licensed under the MIT license.
<https://opensource.org/licenses/MIT>
Copyright (c) 2018 Switch Science, inc.
import pyb
import network
import machine
import usocket
import utime
spi = pyb.SPI(1)
cs = machine.Pin(pyb.Pin.board.X5, machine.Pin.OUT)
def setMacAddress(address):
"""
COPYRIGHT
This code is licensed under the MIT license.
<https://opensource.org/licenses/MIT>
Copyright (c) 2017 Switch Science, inc.
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
@SwitchScienceCode
SwitchScienceCode / motiontweet.agent.nut
Created June 2, 2017 08:24
Electric Imp Explorer Kit Sample Code: Motion Detection by Tweet
// Import libraries
#require "Twitter.class.nut:1.2.1"
// Declare global variables
tweeter <- null;
// Define functions
function tweetback(data) {
// This function is called after a Tweet is successfully posted
server.log("Tweet tweeted");
@SwitchScienceCode
SwitchScienceCode / ledapi.agent.nut
Last active July 1, 2017 00:12
Electric Imp Explorer Kit Sample Code: Agents
// Log the URLs we need
server.log("Turn LED On: " + http.agenturl() + "?led=1");
server.log("Turn LED Off: " + http.agenturl() + "?led=0");
function requestHandler(request, response) {
try {
// Check if the user sent led as a query parameter
if ("led" in request.query) {
// If they did, and led = 1 or 0, set our variable to 1
if (request.query.led == "1" || request.query.led == "0") {
@SwitchScienceCode
SwitchScienceCode / helloworld.device.nut
Last active June 7, 2017 00:59
Electric Imp Explorer Kit Sample Code: Hello World
// Import Electric Imp’s WS2812 library
#require "WS2812.class.nut:3.0.0"
// Set up global variables
spi <- null;
led <- null;
state <- false;
// Define the loop flash function
function flash() {