Close

first version boards are in

A project log for LED displays on Arduinos - a collection

for building clocks and bring them anywhere you want, even integrated a temperature sensor, if you're into that kind of stuff

davedarkodavedarko 10/01/2015 at 22:560 Comments

and here is the code for the LM75 on board the trinket shield, which finally works.

/*
 March 6, 2014
 Spark Fun Electronics
 Nathan Seidle
 Updates by Joel Bartlett
 
 This code is originally based Dean Reading's Library deanreading@hotmail.com
 http://arduino.cc/playground/Main/SevenSegmentLibrary
 He didn't have a license on it so I hope he doesn't mind me making it public domain: 
 This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
 
 This sketch provides a simple counter example for the HP Bubble display from SparkFun.
 https://www.sparkfun.com/products/12710
 
 Pinout for HP Bubble Display:
 1:  Cathode 1
 2:  Anode E
 3:  Anode C
 4:  Cathode 3
 5:  Anode dp
 6:  Cathode 4
 7:  Anode G
 8:  Anode D
 9:  Anode F
 10: Cathode 2
 11: Anode B
 12: Anode A
 */
#include <Wire.h>
#include "SevSeg.h"

//Create an instance of the object.
SevSeg myDisplay;

//Create global variables
unsigned long timer;
int deciSecond = 0;
int f;
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  int displayType = COMMON_CATHODE; //Your display is either common cathode or common anode


  //This pinout is for a bubble dispaly
  //Declare what pins are connected to the GND pins (cathodes)
  int digit1 = 3; //Pin 1
  int digit2 = 4; //Pin 10
  int digit3 = 5; //Pin 4
  int digit4 = 6; //Pin 6

    //Declare what pins are connected to the segments (anodes)
  int segA = 8; //Pin 12
  int segB = 9; //Pin 11
  int segC = 10; //Pin 3
  int segD = 11; //Pin 8
  int segE = 12; //Pin 2
  int segF = 13; //Pin 9
  int segG = 14; //Pin 7
  int segDP= 15; //Pin 5

    int numberOfDigits = 4; //Do you have a 1, 2 or 4 digit display?

  myDisplay.Begin(displayType, numberOfDigits, digit1, digit2, digit3, digit4, segA, segB, segC, segD, segE, segF, segG, segDP);

  myDisplay.SetBrightness(100); //Set the display to 100% brightness level

  // timer = millis();
}

void loop()
{


    char tempString[10]; //Used for sprintf
    sprintf(tempString, "%4d", f); //Convert deciSecond into a string that is right adjusted
    myDisplay.DisplayString(tempString, 4); //(numberToDisplay, decimal point location in binary number [4 means the third digit])

if (millis() - timer >= 1000)
  {
  Wire.write(0x00);  
  Wire.requestFrom(72, 2);  
  
  while(Wire.available()) 
  {
    int8_t msb = Wire.read();
    int8_t lsb = Wire.read();

    // strip one bit of the lsb
    lsb = (lsb & 0x80 ) >> 7; // now lsb = 0 or 1
    f = msb * 10 + 5 * lsb;    
    // add to to form an float
    Serial.println(f,1);
  }
timer = millis();

  }

}

Discussions