Close
0%
0%

Teensy 3.1 for Bitcoin

Bought a Teensy with Bitcoins from the Hackaday General Store. This project is a log of what I've done with it.

Similar projects worth following
My attempts at doing stuff with the Teensy 3.1

I'm using the Teensy Audio Library and the microphone with the Teensy to do some Fast Fourier Transforms for spectral analysis.

Why? To blink LEDs of course!

View all 6 components

  • Changes

    Richard Hogben06/13/2015 at 19:59 0 comments

    Current state:

    I've switched out the mic for better gain, and now have a small Neopixel ring for display.

    Updated sketch

    #include <Adafruit_NeoPixel.h>
    #include <avr/power.h>
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    
    #define PIN 5
    
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
    AudioInputAnalog         adc1;
    AudioAnalyzeFFT1024      myFFT;
    AudioConnection          patchCord1(adc1, 0, myFFT, 0);
    
    int dled = 13;
    
    void setup() {
      pinMode(dled, OUTPUT);
      AudioMemory(12);
      
      // Configure the window algorithm to use
      myFFT.windowFunction(AudioWindowHanning1024);
      
      strip.begin();
      strip.show(); // Initialize all pixels to 'off'
    }
    
    void loop() {
      float n;
      int i;
      int p;
    
      if (myFFT.available()) {
        // each time new FFT data is available
        for (i=0; i<strip.numPixels(); i++) {
          n = myFFT.read(i+5);
          if (n > 0.05) {
            p = (n+i)*1000;
            digitalWrite(dled, HIGH);
            strip.setPixelColor(i, Wheel(p));
            strip.show();
          }
        }
        digitalWrite(dled, LOW);
        colorWipe(strip.Color(0, 0, 0), 1);
      }
    }
    
    // Fill the dots one after the other with a color
    void colorWipe(uint32_t c, uint8_t wait) {
      for(uint16_t i=0; i<strip.numPixels(); i++) {
          strip.setPixelColor(i, c);
          strip.show();
          delay(wait);
      }
    }
    
    // Input a value 0 to 255 to get a color value.
    // The colours are a transition r - g - b - back to r.
    uint32_t Wheel(byte WheelPos) {
      WheelPos = 255 - WheelPos;
      if(WheelPos < 85) {
       return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
      } else if(WheelPos < 170) {
        WheelPos -= 85;
       return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
      } else {
       WheelPos -= 170;
       return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
      }
    }
    

  • First Arduino sketch

    Richard Hogben06/06/2015 at 03:36 0 comments

    Mic is on pin 16 and LEDs are on PWM 23 and 22. The Teensy LED lights up for general frequency detection and the two LEDs light up and fade out at two higher frequencies.

    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    
    AudioInputAnalog         adc1;
    AudioAnalyzeFFT1024      myFFT;
    AudioConnection          patchCord1(adc1, 0, myFFT, 0);
    
    int aledg = 23;
    int aledr = 22;
    int dled = 13;
    int brightness1 = 0;
    int brightness2 = 0;
    
    void setup() {
      pinMode(aledg, OUTPUT);
      pinMode(aledr, OUTPUT);
      pinMode(dled, OUTPUT);
      AudioMemory(12);
      
      // Configure the window algorithm to use
      myFFT.windowFunction(AudioWindowHanning1024);
    }
    
    void loop() {
      float n;
      int i;
    
      if (myFFT.available()) {
        // each time new FFT data is available
        for (i=4; i<175; i++) {
          n = myFFT.read(i);
          if (n >= 0.10) {
            digitalWrite(dled, HIGH);
          }
        }
        if ( myFFT.read(16) >= 0.10 ) {
          brightness1 = 255;
        }
        if ( myFFT.read(13) >= 0.10 ) {
          brightness2 = 255;
        }
        analogWrite(aledg, brightness1);
        analogWrite(aledr, brightness2);
        brightness1 = brightness1 -5;
        brightness2 = brightness2 -5;
        digitalWrite(dled, LOW);
      }
    }

View all 2 project logs

Enjoy this project?

Share

Discussions

davedarko wrote 06/06/2015 at 07:06 point

I first thought you're gonna make a bitcoin miner with a teensie :D

  Are you sure? yes | no

Richard Hogben wrote 06/06/2015 at 18:25 point

I would need a lot more Teensies :P

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates