Go Down

Topic: Paying $50 to whomever can get my digispark to work with I2C & 16x2 LCD (Read 581 times) previous topic - next topic

matt_funder27

No such luck, if I follow the instructions as described, I get an error that lcd is not declared in this scope
It complies if i use the example within the Adagfruit folder... so not sure whats going on there.

I completely replaced the TinyWireM file, and I already have all of the cores it was wanting me to use.

I added in coding from the other sketches to get it to compile, but that just puts me back at square one.


Code: [Select]
#include <TinyWireM.h>                 // ATtiny I2C communication
//#include <Adafruit_RGBLCDShield.h> // RGB LCD Shield communications
#include <LiquidCrystal_I2C.h> 
//Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define GPIO_ADDR     0x27 
LiquidCrystal_I2C lcd(GPIO_ADDR,16,2);
long secs = 0;

void setup()
{

  lcd.begin(16, 2); // set up the LCD's number of columns and rows.
  lcd.setBacklight(7); // For monochrome LCD lcd.setBacklight(ON)
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Hello World!");
}

void loop()
{
 
}

wolframore

You reverted back to #define GPIO_ADDR     0x27

Please try 0x38;

 if (that doesn't work)  0x3F 

:)
Bad boys rate our young girls but Violet goes willingly :)
- this is a mnemonic from BEC

matt_funder27

I tried both, but I was just able to get a I2C scanner working,


C device found at address 0x3F  !
done



wolframore

Bad boys rate our young girls but Violet goes willingly :)
- this is a mnemonic from BEC

david_prentice

Go on.   He posted a photo of a PCF8574A with unmounted links on the A0, A1, A2 pins.   i.e. Slave = 0x3F

However,   it is much safer to install Bill Perry's HD44780 library or run an I2C sniffer program.   Then you will know the address.

Or you could just use Codevision C Compiler.  Which supports the I2C backpack.

David.

matt_funder27

not yet, I am going bake through all of the previous libraries Ive used to see if any will work using the 0X3F library.

wolframore

that's the first address we tried... try David's suggestion on the library.  I can see why I2C is so important on attiny.  what are you making?  Why not just use a 328?

Do we still know if pin 5 and 7 are still good?
Bad boys rate our young girls but Violet goes willingly :)
- this is a mnemonic from BEC

wolframore

OK try this...


Go here and download:
https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads/

seems not all the libraries work with ATTINY.

Open file I2CIO.cpp

After line 34 insert the code below:

#if defined(__AVR_ATtiny84__) || (__AVR_ATtiny2313__)
#include "TinyWireM.h"      // include this if ATtiny85 or ATtiny2313
#define Wire TinyWireM
#else
#include <Wire.h>           // original lib include
#endif







Code: [Select]


#include <TinyWireM.h>                 // ATtiny I2C communication

#include <LiquidCrystal.I2C.h> 

#define GPIO_ADDR     0x3F 
LiquidCrystal_I2C lcd(GPIO_ADDR, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
long secs = 0;

void setup()
{

  lcd.begin(16, 2); // set up the LCD's number of columns and rows.
  lcd.setBacklight(ON);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Hello World!");
}

void loop()
{
 
}

Bad boys rate our young girls but Violet goes willingly :)
- this is a mnemonic from BEC

matt_funder27

that's the first address we tried... try David's suggestion on the library.  I can see why I2C is so important on attiny.  what are you making?  Why not just use a 328?

Do we still know if pin 5 and 7 are still good?
I want to use a micro controller that is under $3 for my project. Eventually, I would like to just use the Attiny85 alone and not on the digispark. I just Received my Uno, so I can test the screen and I2C.

I will also try your recommendation and reply.

wolframore

Good luck... I get 328P chips for $1.50 and make my own.  Attiny isn't a huge savings for the issues it can cause.
Bad boys rate our young girls but Violet goes willingly :)
- this is a mnemonic from BEC

matt_funder27

Im a man of my word, Wofl please send me a personal message to declare how you would like your payment.

The code below worked for me.


Code: [Select]
/*
 * Interactive nametag sketch for ATtiny85. Based on the Digispark
 * ATtiny LCD example and the Adafruit "Measuring Sound Levels" example.
 * Every 12000 milliseconds will change the display from my name to my website.
 * On the second line, will measure and display sound levels.
 * For more info check: https://platis.solutions/blog/2015/03/22/diy-interactive-name-tag/
 * ATtiny85 I2C pins:
 * ATtiny Pin 5 = SDA on DS1621  & GPIO
 * ATtiny Pin 7 = SCK on DS1621  & GPIO
 */

#include <TinyWireM.h>                  // I2C Master lib for ATTinys which use USI - comment this out to use with standard arduinos
#include <LiquidCrystal_attiny.h>          // for LCD w/ GPIO MODIFIED for the ATtiny85

#define GPIO_ADDR     0x3F
LiquidCrystal_I2C lcd(GPIO_ADDR, 16, 2); // set address & 16 chars / 2 lines

const short micPin = A3;
const short sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
const unsigned long nameInterval = 12000;
unsigned long prevNameChange = 0;
short state = 1;
unsigned int sample;

void setup() {
  lcd.init();                           // initialize the lcd
  lcd.backlight();                      // Print a message to the LCD.
  lcd.print("Name: Dimitris");
}

void loop() {
  printName();
  printTemp();
}

void printName() {
  if (millis() - prevNameChange > nameInterval) {
    lcd.setCursor(0, 0);
    if (state) {
      lcd.print("platis.solutions");
    } else {
      lcd.print("Name: Dimitris  ");
    }
    prevNameChange = millis();
    state = !state;
  }
}

void printTemp()
{
  unsigned long startMillis = millis(); // Start of sample window
  unsigned int peakToPeak = 0;   // peak-to-peak level

  unsigned int signalMax = 0;
  unsigned int signalMin = 1024;

  // collect data for 50 mS
  while (millis() - startMillis < sampleWindow)
  {
    sample = analogRead(micPin);
    if (sample < 1024)  // toss out spurious readings
    {
      if (sample > signalMax)
      {
        signalMax = sample;  // save just the max levels
      }
      else if (sample < signalMin)
      {
        signalMin = sample;  // save just the min levels
      }
    }
  }
  peakToPeak = signalMax - signalMin;  // max - min = peak-peak amplitude
  printBars(peakToPeak);
}

void printBars(int bars) {
  if (bars > 14) bars = 14;
  for (int i = 0; i < 15; i++) {
    lcd.setCursor(i, 1);
    if (i <= bars) {
      lcd.print("*");
    } else {
      lcd.print(" ");
    }
  }
}

Paul__B

I want to use a micro controller that is under $3 for my project. Eventually, I would like to just use the Attiny85 alone and not on the digispark. I just Received my Uno, so I can test the screen and I2C.
If you want a minimal system, the Pro Mini will cost you less than $2 from China (where else?), is more capable, and you get the PCB with all support parts fitted.  I can't see the point in re-inventing the wheel with bare chips.  :smiley-roll:

wolframore

Matt I just read through your code. That's pretty fun. Is this for s maker faire or a hacker event???
Bad boys rate our young girls but Violet goes willingly :)
- this is a mnemonic from BEC

Go Up