Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
void setup() {
Serial.begin(9600);
}
void loop() {
for (int i = 0; i < 10; i++) {
int val = analogRead(A0 + i);
int mapped = map(val, 0, 1023, 0, 9);
Serial.print(mapped);
Serial.print(" ");
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nbogie
nbogie / ScorerForReactionGame.js
Last active October 30, 2017 00:40
Scorer for micro:bit reaction game. Uses servo to display score.
let angle = 0
radio.onDataPacketReceived( ({ receivedNumber }) => {
if (receivedNumber < 0) {
basic.showIcon(IconNames.Angry)
} else {
pins.servoWritePin(AnalogPin.P2, pins.map(
3000 - Math.min(receivedNumber, 3000),
0,
3000,
5,
@nbogie
nbogie / reactiongame.js
Last active October 30, 2017 00:35
micro:bit reaction game
let startTime = 0
let scoring = false
let playing = false
let winTime = 0
input.onPinPressed(TouchPin.P0, () => {
startRound()
})
function handleWin() {
winTime = input.runningTime() - startTime
basic.showNumber(winTime)
@nbogie
nbogie / TeensyAudioFirstSynth.ino
Created October 10, 2017 23:30
A quick first noisemaker patch with Teensy Audio library and a single pot.
#include <synth_simple_drum.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=69.01041030883789,238.01041412353516
AudioSynthKarplusStrong string1; //xy=114.01040649414062,78.01041412353516
@nbogie
nbogie / microbit theremin
Last active September 28, 2017 23:58
us-100 ultrasonic theremin on microbit. Uses fizban99's code to get distance.
from microbit import uart, pin14, pin15, pin2, pin1, pin0, sleep, display
from sys import print_exception
import music
#This is a simplified version of the library here:
# https://github.com/fizban99/microbit_us100
#
# TODO: Perhaps see the above for exception handling.
class US100: