Pages: [1]   Go Down
Author Topic: i2c ebay display  (Read 793 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.
I'm new to arduino, and all sort of coding.
these is my display: http://www.ebay.com/itm/IIC-I2C-0-96-128X64-White-OLED-Display-Module-AVR-PIC-Arduino-Compatible-/170842973484?pt=LH_DefaultDomain_0&hash=item27c708e52c
And i want my display to show the analogRead (A6) or other variable.

here is my code:


void setup()
{
  Wire.begin();
  
  Serial.begin(9600);
  pinMode(A4, OUTPUT);
  pinMode(A5, INPUT);
  Reset();
}
void loop()
{
 
  const char* a1 =analogRead(A6);


  digitalWrite(13,HIGH);
  digitalWrite(A4,HIGH);
  delay(30);
  Display8x16Str(0,0, a1);
  Display8x16Str(2,20, "TEST");
  Display8x16Str(4,0, "Wellcom to use");
  Display8x16Str(6,0, "Gem.Arduino");
  digitalWrite(A4,LOW);
  delay(200);

  Reset();

 }
}

and here is the error: "TEST_DISPLAY_POTMETER:178: error: invalid conversion from 'int' to 'const char*'"

I tested it without the a1, and used "test" instead, and then it works well.

Do someone have any idea what i can write?


« Last Edit: September 27, 2012, 03:12:20 pm by bjhund » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8967
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Where is "Display8x16Str()" defined?  Is there a similar function for display an integer?
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is the whole code, sorry.

but instead of "TEST1" i would like to put analogRead(A6), bet then its creating the error i wrote above.
Code:

// Wire Master Writer
// by Nicholas Zambetti <http://www.zambetti.com>

// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the "Wire Slave Receiver" example for use with this

// Created 29 March 2006

// This example code is in the public domain.

#include <Wire.h>

#define OLED_ADDRESS    0x51

#define WRITE_CMD       0x01
#define WRITE_DAT       0x02
#define RESET           0x03

#define DISP_8X16STR    0x10
#define DISP_AREA       0x11
#define FILL_AREA       0x12
#define SET_SCROHOR     0x13
#define SET_SCROVER     0x14
#define SET_SCROVERHOR  0x15

#define SET_ADDRESS     0x21

#define PAGE0           0x00
#define PAGE1           0x01
#define PAGE2           0x02
#define PAGE3           0x03
#define PAGE4           0x04
#define PAGE5           0x05
#define PAGE6           0x06
#define PAGE7           0x07

#define SCROLL_UP       0x01
#define SCROLL_DOWN     0x00
#define SCROLL_RIGHT    0x26
#define SCROLL_LEFT     0x27
#define SCROLL_VR       0x29
#define SCROLL_VL       0x2A

#define FRAMS_2         0x07
#define FRAMS_3         0x04
#define FRAMS_4         0x05
#define FRAMS_5         0x00
#define FRAMS_25        0x06
#define FRAMS_64        0x01
#define FRAMS_128       0x02
#define FRAMS_256       0x03

void Display8x16Str(uint8_t page, uint8_t column, const char *str)
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(DISP_8X16STR);
    Wire.write(page);
    Wire.write(column);
    
    while(*str != '\0')
    {
         Wire.write(*str++);
    }
    Wire.endTransmission();
}
void FillArea(uint8_t spage, uint8_t epage,uint8_t scolumn, uint8_t ecolumn,uint8_t filldata)
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(FILL_AREA);
    Wire.write(spage);
    Wire.write(epage);
    Wire.write(scolumn);
    Wire.write(ecolumn);
    Wire.write(filldata);
    Wire.endTransmission();
}
void ScrollingHorizontal(uint8_t lr, uint8_t spage, uint8_t epage,uint8_t frames)
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(SET_SCROHOR);
    Wire.write(lr);
    Wire.write(spage);
    Wire.write(epage);
    Wire.write(frames);
    Wire.endTransmission();
}
void ScrollingVertical(uint8_t scrollupdown, uint8_t rowsfixed, uint8_t rowsscroll, uint8_t scrollstep, uint8_t stepdelay)
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(SET_SCROVER);
    Wire.write(scrollupdown);
    Wire.write(rowsfixed);
    Wire.write(rowsscroll);
    Wire.write(scrollstep);
    Wire.write(stepdelay);
    Wire.endTransmission();
}
void ScrollingVertivalHorizontal(uint8_t fixedarea, uint8_t scrollarea, uint8_t vlr, uint8_t spage, uint8_t epage, uint8_t frames, uint8_t offset)
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(SET_SCROVERHOR);
    Wire.write(fixedarea);
    Wire.write(scrollarea);
    Wire.write(vlr);
    Wire.write(spage);
    Wire.write(epage);
    Wire.write(frames);
    Wire.write(offset);
    Wire.endTransmission();
}
void DeactivateScroll()
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(WRITE_CMD);
    Wire.write(0x2E);
    Wire.endTransmission();
}
void WriteCommand(const char *cmd)
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(WRITE_CMD);    
    while(*cmd != '\0')
    {
         Wire.write(*cmd++);
    }
    Wire.endTransmission();
}
void WriteData()
{
    unsigned int i;
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(WRITE_DAT);    
    for (i=0; i<20; i++)
    {
        // Wire.send(0xF0);  
    }
    for (i=0; i<20; i++)
    {
        // Wire.send(0x0F);  
    }
    for (i=0; i<32; i++)
    {
         Wire.write(0xFF);  
    }
    Wire.endTransmission();
}
void SetAddress(uint8_t page, uint8_t column)
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(SET_ADDRESS);    
    Wire.write(page);
    Wire.write(column);
    Wire.endTransmission();
}
void Reset()
{
    Wire.beginTransmission(OLED_ADDRESS);
    Wire.write(RESET);    
    Wire.endTransmission();
}
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  pinMode(A4, OUTPUT);
  pinMode(A5, INPUT);
  Reset();
}
void loop()
{
  digitalWrite(A4,HIGH);
  delay(30);
  Display8x16Str(0,0, "TEST1:");
  Display8x16Str(2,20, "TEST2");
  Display8x16Str(4,0, "Wellcom to use");
  Display8x16Str(6,0, "Gem.Arduino");
  digitalWrite(A4,LOW);
delay (200);
  Reset();
}
« Last Edit: September 28, 2012, 06:42:05 am by bjhund » Logged

France
Offline Offline
Edison Member
*
Karma: 38
Posts: 1012
Scientia potentia est.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello and welcome smiley

In your code, a1 is an integer variable (a number), because analogRead() return an integer. But the function Display8x16Str expect a string variable. So you must convert the integer into a string, maybe this will help: http://www.arduino.cc/playground/Code/PrintingNumbers and also have a look at this: http://arduino.cc/en/Reference/StringConstructor . Good luck smiley
« Last Edit: September 27, 2012, 08:15:50 pm by guix » Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 74
Posts: 7260
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use the code tag next time you post code (see the red box?):

Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for answers  smiley
have a lot to do to really find out how arduino works smiley-razz

trying to find some library that will coop with my problem, just to make it look nicer, and cleaner smiley
Logged

Pages: [1]   Go Up
Jump to: