Giasone
Published © GPL3+

Hacking Your Maker Faire Rome Badge

Learn how to hack you Maker Faire Badge to mount a 128x64 oled display on it.

BeginnerWork in progress1,358
Hacking Your Maker Faire Rome Badge

Things used in this project

Hardware components

SparkFun Maker Faire Badge
×1
SSD1306 128x64 OLED Display
×1
40 cm AWG30 wire
×1
2 M2 nuts and bolts
×1
SparkFun FTDI Basic Breakout - 3.3V
SparkFun FTDI Basic Breakout - 3.3V
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Desoldering Pump
Drilling rotary tool

Story

Read more

Schematics

Arduino UNO and SSD1306 OLED 128x64

Arduino UNO and SSD1306 OLED 128x64 display connection diagram

Code

sparkfun_badge_1306.ino

C/C++
/*********************************************************************
SparkFun Maker Faire Badge and a Bichrome OLED SSD1306 128x64

Author: Gianluca Urgese <g.urgese@jasone.it> @2015

This is an example for SparkFun Maker Faire Badge and a Bichrome OLEDs 
based on SSD1306 drivers

This example is for a 128x64 size display using I2C to communicate
2 pins are required to interface

GND goes to ground
Vin goes to 5V
Data to I2C SDA pin A4
Clk to I2C SCL pin A5 
RST to digital pin 4 (if yor display have RST)


CREDITS
Library: Adafruit_GFX and Adafruit_SSD1306 by Limor Fried/Ladyada for Adafruit Industries
Code based on: 
library example ssd1306_128x64_i2c
Arduino example toneMelody by Tom Igoe

BSD license, check license.txt for more information
All text above, and the splash screen must be included in any redistribution
*********************************************************************/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX_i2c.h>
#include <Adafruit_SSD1306_i2c.h>
#include "pitches.h"

// Reset pin not used for my lcd version
#define OLED_RESET 4
Adafruit_SSD1306_i2c display(OLED_RESET);

#define LED 13
#define BUZZ 2

// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3, NOTE_G3, NOTE_A3, NOTE_G3, 0, NOTE_B3, NOTE_C4
};

// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4, 4, 4, 4, 4
};

#if (SSD1306_LCDHEIGHT != 64)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

void setup()   {                
  Serial.begin(9600);

  pinMode(LED, OUTPUT);
  pinMode(BUZZ, OUTPUT);

  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 

  display.display();
  delay(getTemp()*100);
  display.clearDisplay();

  showInfo();
  playSound();
}


void loop() {

  digitalWrite(LED, HIGH);  
  delay(getTemp()*100);              
  digitalWrite(LED, LOW); 
  delay(getTemp()*100);

  drawLine();
  display.display();
  delay(getTemp()*100);
  display.clearDisplay();

  drawWave();
  display.display();
  delay(getTemp()*100);
  display.clearDisplay();
  
  showInfo();
  delay(getTemp()*100);
  
}

void drawLine() {  
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(0, 0, i, display.height()-1, WHITE);
    display.display();
  }
  for (int16_t i=0; i<display.height(); i+=4) {
    display.drawLine(0, 0, display.width()-1, i, WHITE);
    display.display();
  }
  delay(250);
  
  display.clearDisplay();
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(0, display.height()-1, i, 0, WHITE);
    display.display();
  }
  for (int16_t i=display.height()-1; i>=0; i-=4) {
    display.drawLine(0, display.height()-1, display.width()-1, i, WHITE);
    display.display();
  }
  delay(250);
  
  display.clearDisplay();
  for (int16_t i=display.width()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, i, 0, WHITE);
    display.display();
  }
  for (int16_t i=display.height()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, 0, i, WHITE);
    display.display();
  }
  delay(250);

  display.clearDisplay();
  for (int16_t i=0; i<display.height(); i+=4) {
    display.drawLine(display.width()-1, 0, 0, i, WHITE);
    display.display();
  }
  for (int16_t i=0; i<display.width(); i+=4) {
    display.drawLine(display.width()-1, 0, i, display.height()-1, WHITE); 
    display.display();
  }
  delay(250);
}

void playSound(void) {

  for (int thisNote = 0; thisNote < 8; thisNote++) {
    
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(BUZZ, melody[thisNote], noteDuration);

    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);

    noTone(BUZZ);
  }
}

void showInfo(void) {
  // text display tests
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(32,0);
  display.println("Maker Faire");
  display.setCursor(35,8);
  display.println("Rome 20115");

  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(17,20);
  display.println("GIANLUCA"); 
  display.setCursor(27,40);
  display.println("URGESE");
  display.setTextSize(1);
  display.setTextColor(BLACK, WHITE);
  display.println(" Think, make, create!");
  display.display();
  delay(2000);
  
}

double getTemp(void)
{
  unsigned int wADC;
  double t;

  // The internal temperature has to be used
  // with the internal reference of 1.1V.
  // Channel 8 can not be selected with
  // the analogRead function yet.

  // Set the internal reference and mux.
  ADMUX = (_BV(REFS1) | _BV(REFS0) | _BV(MUX3));
  ADCSRA |= _BV(ADEN);  // enable the ADC

  delay(20);            // wait for voltages to become stable.

  ADCSRA |= _BV(ADSC);  // Start the ADC

  // Detect end-of-conversion
  while (bit_is_set(ADCSRA,ADSC));

  // Reading register "ADCW" takes care of how to read ADCL and ADCH.
  wADC = ADCW;

  // The offset of 324.31 could be wrong. It is just an indication.
  t = (wADC - 324.31 ) / 1.22;

  // The returned temperature is in degrees Celcius.
  return (t);
}


void drawWave() {
  int i; 
  int x = 0;
  int py[128];
  int y;
  float a;
  byte w = display.width();
  byte h = display.height();
  display.drawLine(0, h-10, w, h-10, WHITE); // horiz line near bottom  x1,y1, x2,y2, color
  display.setTextSize(1);
  display.setCursor(4,display.height()-28);
  display.display();

  for (i=0; i<w*4; i++) {  // N full-width sweeps
    x++;
    if (x > w) {
      x=1;
      //display.clearDisplay(); 
    }
    //digitalWrite(LED2pin,(x<5)); // flash short pulse at beginning of each cycle
    display.drawPixel(x, py[x], BLACK);
    y = byte(26*(1+sin(i/(3.1416*2))));
    display.drawPixel(x, y, WHITE);  // draw a single pixel
    py[x]=y;
    if (x%4==0)    display.display(); // refresh less often to speed up system
  }
}

pitches.h

C/C++
/*************************************************
 * Public Constants
 *************************************************/

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978

Adafruit_SSD1306

SSD1306 oled driver library for 'monochrome' 128x64 and 128x32 OLEDs!

Adafruit-GFX-Library

Adafruit GFX graphics core library, this is the 'core' class that all our other graphics libraries (will eventually) derive from. Still beta (but working)

Credits

Giasone
2 projects • 15 followers
Developer, maker

Comments