Show Posts
Pages: 1 ... 62 63 [64] 65 66 ... 110
946  Using Arduino / Displays / Re: Sparkfun color LCD shield question, possible problem. on: October 11, 2012, 03:24:24 am
If you go to the downloads page (button which says downloads to the top rifght of the repository), they are all seperated into individual zip files, one for each version.
All the old versions are there because that is how they are stored on my computer in the git folder.
947  Using Arduino / Programming Questions / Re: Wire library includes, but error says "Not Defined" on: October 10, 2012, 05:51:55 pm
I believe then it is just a case of changing:

#include <BMP085.h>


#include "BMP085.h"

The two are different. The first implies a system file (somewhere buried deep in the /hardware/tools/avr/avr/ folder), the second a local file, such as arduino libraries and files in your sketch folder.
948  Using Arduino / Programming Questions / Re: Wire library includes, but error says "Not Defined" on: October 10, 2012, 04:56:29 pm
Have you put a semicolon at the end of the class definition in BMP085.h?

(Post your code! Otherwise it is impossible to help beyond chance guesses)
949  Using Arduino / Displays / Re: Sparkfun color LCD shield question, possible problem. on: October 10, 2012, 04:52:07 pm
If you get a blank screen it *usually* means you have the wrong driver. If you tried EPSON in your first attempt and that didn't work, try PHILLIPS_0
(Side note: It looks the same as mine in terms of connector colour, and mine is PHILLIPS, but then you can't really tell which is why my library supports many variants of both phillips and epson).
950  Using Arduino / Microcontrollers / Re: atmega324p bootloader can't write flash on: October 10, 2012, 04:35:45 pm
You have specified to avrdude to program the chip using ISP (note the avrisp), and yet you are trying to use a bootloader. The two are very different.

Off the top of my head I can't remeber what ATmegaBOOT uses in relation to avrdude. I think that optiboot is 'arduino' (instead of avrisp), or is it 'stk500v1'. Would have to check.

Try this:
avrdude -c arduino -p m324p -P com1 -b 19200 -D -U flash:w:main_blinking.hex:i
951  Using Arduino / Microcontrollers / Re: My Core + Bootloader Version for ATTiny's on: October 10, 2012, 02:08:19 am
Basically at the expense of 576B of flash you get to upload via serial port in the same way an arduino does. This means fewer pin need to be broken out for programming.
Another advantage is that my bootloader version tunes the internal oscillator which makes serial comma more reliable.
952  Using Arduino / Microcontrollers / My Core + Bootloader Version for ATTiny's on: October 09, 2012, 06:02:40 pm
Just for those who are interested, I have finally got around to uploading my version of the 'tiny' core for Arduino. Along with that I have included my version of Optiboot which works with the ATtiny84 and ATtiny85 processors (The optiboot version includes TinyTuner built in to calibrate the oscillator allowing a Software UART to be reliable).

The Core is hosted on github @:

Beta testers are very welcome as there are probably a few bugs in it which need ironing out (with the exception of the bootloader which is fully tested and functional).

I have also uploaded the fix for the PCREL error to the repository so it is easy to find.
953  Using Arduino / Programming Questions / Re: Combining Serial prints ... HELP! on: October 09, 2012, 03:49:32 pm
Just for the sake of interest, the method using multiple print() calls is faster than the sprintf() method (in one simple test).

For a loop of 100 calls to printing the data for each, the results are:
multiple print()'s : 210556 us
sprintf() : 210972 us

That is at 115200 baud and the same group of calls as in that snippet of code you posted.

For a loop of 10000 calls to printing the data for each, the results are:
multiple print()'s : 23378412 us
sprintf() : 22798020 us

Interesting, sprintf() seems to have recovered. I think the first test may have been biased as for the first few iterations sprintf() had more to print as micros() had a larger value (more decimal digits)

But yeah as has been pointed out:
115,200 baud = 11520 bytes per second = 11.52 bytes per millisecond, not including the time it takes to get the data and load it into the buffer etc.
954  Using Arduino / Programming Questions / Re: Combining Serial prints ... HELP! on: October 09, 2012, 02:35:17 pm
char buffer[100]; //This is where the data will be merged into. Ideally you should make this as small as you can whilst still having enough room
sprintf(buffer,"1 %ul %d %d %d %d %d", millis(), distance, pressure, prSwitch, Fldtemp); //merge together
Serial.println(buffer); //send

Basically sprintf has a set of special characters (the %_ where the _ is a letter(s)). As it works along it replaces each of these with the corresponding variable (first % is the first variable, second % is the second variable and so on).

Each of the special charaters formats the variable in a different way. For example %d takes an integer and converts it to a string of numbers. %c takes a byte and prints the corresponding ascii character (so 30 would print ' ' (space)). %ul takes an unsigned long type (which is why it is used for millis()).
There are others as well, you would have to look on the cplusplus reference (if you google sprintf() you should find it).

Note that in my example as I don't know the variable types of your numbers I have assumed that they are all bytes or integers (so %d) except for millis() which I know returns an unsigned long.
955  Using Arduino / Displays / Re: Nokia LCD display shield question on: October 08, 2012, 09:17:41 am
Yep. there is no funtion buoy in to do that so you will have to do it manually. I have some code from a previous project which I can find for you if you would like.
956  Using Arduino / Displays / Re: Nokia LCD display shield question on: October 08, 2012, 07:50:09 am
If you go through that function and find stuff like this:
if (cts = true){
 //always called as assignment returns true

if (cts = false){
 //neve called as assignment returns true
It is wrong. It should be like this:
if (cts == true){
 //called when cts is true

if (cts == false){
 //called when cts is false

Can you see the difference?

Your code is using an assignment (set cts to equal true) which regardless of the math you do always returns true.
The second code block is using an equality operator - the statement is true if this IS EQUAL to that, else it is false.

For cases where you are checking if something is true or false, you are best using this:
if (cts){
 //called when cts is true

if (!cts){
  //called when cts is NOT true, i.e. false
This is important as when something returns true you can't guarantee that it is == to 0x01 (which is what true is defined as). In the world of C/C++, boolean true is anything which is not 0.
957  Using Arduino / Programming Questions / Re: Code help on: October 07, 2012, 06:24:55 pm
Right, I went back to you first post and worked from what you said was wrong. A couple of corrections later:
#define PIN_SCE   7
#define PIN_RESET 6
#define PIN_DC    5
#define PIN_SDIN  4
#define PIN_SCLK  3
int ledlight = 13;
#define LCD_C     LOW
#define LCD_D     HIGH

#define LCD_X     84
#define LCD_Y     48
#include <PS2Keyboard.h>

const int DataPin = 8;
const int IRQpin =  2;
PS2Keyboard keyboard;
static const byte ASCII[][5] =
 {0x00, 0x00, 0x00, 0x00, 0x00} // 20 
,{0x00, 0x00, 0x5f, 0x00, 0x00} // 21 !
,{0x00, 0x07, 0x00, 0x07, 0x00} // 22 "
,{0x14, 0x7f, 0x14, 0x7f, 0x14} // 23 #
,{0x24, 0x2a, 0x7f, 0x2a, 0x12} // 24 $
,{0x23, 0x13, 0x08, 0x64, 0x62} // 25 %
,{0x36, 0x49, 0x55, 0x22, 0x50} // 26 &
,{0x00, 0x05, 0x03, 0x00, 0x00} // 27 '
,{0x00, 0x1c, 0x22, 0x41, 0x00} // 28 (
,{0x00, 0x41, 0x22, 0x1c, 0x00} // 29 )
,{0x14, 0x08, 0x3e, 0x08, 0x14} // 2a *
,{0x08, 0x08, 0x3e, 0x08, 0x08} // 2b +
,{0x00, 0x50, 0x30, 0x00, 0x00} // 2c ,
,{0x08, 0x08, 0x08, 0x08, 0x08} // 2d -
,{0x00, 0x60, 0x60, 0x00, 0x00} // 2e .
,{0x20, 0x10, 0x08, 0x04, 0x02} // 2f /
,{0x3e, 0x51, 0x49, 0x45, 0x3e} // 30 0
,{0x00, 0x42, 0x7f, 0x40, 0x00} // 31 1
,{0x42, 0x61, 0x51, 0x49, 0x46} // 32 2
,{0x21, 0x41, 0x45, 0x4b, 0x31} // 33 3
,{0x18, 0x14, 0x12, 0x7f, 0x10} // 34 4
,{0x27, 0x45, 0x45, 0x45, 0x39} // 35 5
,{0x3c, 0x4a, 0x49, 0x49, 0x30} // 36 6
,{0x01, 0x71, 0x09, 0x05, 0x03} // 37 7
,{0x36, 0x49, 0x49, 0x49, 0x36} // 38 8
,{0x06, 0x49, 0x49, 0x29, 0x1e} // 39 9
,{0x00, 0x36, 0x36, 0x00, 0x00} // 3a :
,{0x00, 0x56, 0x36, 0x00, 0x00} // 3b ;
,{0x08, 0x14, 0x22, 0x41, 0x00} // 3c <
,{0x14, 0x14, 0x14, 0x14, 0x14} // 3d =
,{0x00, 0x41, 0x22, 0x14, 0x08} // 3e >
,{0x02, 0x01, 0x51, 0x09, 0x06} // 3f ?
,{0x32, 0x49, 0x79, 0x41, 0x3e} // 40 @
,{0x7e, 0x11, 0x11, 0x11, 0x7e} // 41 A
,{0x7f, 0x49, 0x49, 0x49, 0x36} // 42 B
,{0x3e, 0x41, 0x41, 0x41, 0x22} // 43 C
,{0x7f, 0x41, 0x41, 0x22, 0x1c} // 44 D
,{0x7f, 0x49, 0x49, 0x49, 0x41} // 45 E
,{0x7f, 0x09, 0x09, 0x09, 0x01} // 46 F
,{0x3e, 0x41, 0x49, 0x49, 0x7a} // 47 G
,{0x7f, 0x08, 0x08, 0x08, 0x7f} // 48 H
,{0x00, 0x41, 0x7f, 0x41, 0x00} // 49 I
,{0x20, 0x40, 0x41, 0x3f, 0x01} // 4a J
,{0x7f, 0x08, 0x14, 0x22, 0x41} // 4b K
,{0x7f, 0x40, 0x40, 0x40, 0x40} // 4c L
,{0x7f, 0x02, 0x0c, 0x02, 0x7f} // 4d M
,{0x7f, 0x04, 0x08, 0x10, 0x7f} // 4e N
,{0x3e, 0x41, 0x41, 0x41, 0x3e} // 4f O
,{0x7f, 0x09, 0x09, 0x09, 0x06} // 50 P
,{0x3e, 0x41, 0x51, 0x21, 0x5e} // 51 Q
,{0x7f, 0x09, 0x19, 0x29, 0x46} // 52 R
,{0x46, 0x49, 0x49, 0x49, 0x31} // 53 S
,{0x01, 0x01, 0x7f, 0x01, 0x01} // 54 T
,{0x3f, 0x40, 0x40, 0x40, 0x3f} // 55 U
,{0x1f, 0x20, 0x40, 0x20, 0x1f} // 56 V
,{0x3f, 0x40, 0x38, 0x40, 0x3f} // 57 W
,{0x63, 0x14, 0x08, 0x14, 0x63} // 58 X
,{0x07, 0x08, 0x70, 0x08, 0x07} // 59 Y
,{0x61, 0x51, 0x49, 0x45, 0x43} // 5a Z
,{0x00, 0x7f, 0x41, 0x41, 0x00} // 5b [
,{0x02, 0x04, 0x08, 0x10, 0x20} // 5c ¥
,{0x00, 0x41, 0x41, 0x7f, 0x00} // 5d ]
,{0x04, 0x02, 0x01, 0x02, 0x04} // 5e ^
,{0x40, 0x40, 0x40, 0x40, 0x40} // 5f _
,{0x00, 0x01, 0x02, 0x04, 0x00} // 60 `
,{0x20, 0x54, 0x54, 0x54, 0x78} // 61 a
,{0x7f, 0x48, 0x44, 0x44, 0x38} // 62 b
,{0x38, 0x44, 0x44, 0x44, 0x20} // 63 c
,{0x38, 0x44, 0x44, 0x48, 0x7f} // 64 d
,{0x38, 0x54, 0x54, 0x54, 0x18} // 65 e
,{0x08, 0x7e, 0x09, 0x01, 0x02} // 66 f
,{0x0c, 0x52, 0x52, 0x52, 0x3e} // 67 g
,{0x7f, 0x08, 0x04, 0x04, 0x78} // 68 h
,{0x00, 0x44, 0x7d, 0x40, 0x00} // 69 i
,{0x20, 0x40, 0x44, 0x3d, 0x00} // 6a j
,{0x7f, 0x10, 0x28, 0x44, 0x00} // 6b k
,{0x00, 0x41, 0x7f, 0x40, 0x00} // 6c l
,{0x7c, 0x04, 0x18, 0x04, 0x78} // 6d m
,{0x7c, 0x08, 0x04, 0x04, 0x78} // 6e n
,{0x38, 0x44, 0x44, 0x44, 0x38} // 6f o
,{0x7c, 0x14, 0x14, 0x14, 0x08} // 70 p
,{0x08, 0x14, 0x14, 0x18, 0x7c} // 71 q
,{0x7c, 0x08, 0x04, 0x04, 0x08} // 72 r
,{0x48, 0x54, 0x54, 0x54, 0x20} // 73 s
,{0x04, 0x3f, 0x44, 0x40, 0x20} // 74 t
,{0x3c, 0x40, 0x40, 0x20, 0x7c} // 75 u
,{0x1c, 0x20, 0x40, 0x20, 0x1c} // 76 v
,{0x3c, 0x40, 0x30, 0x40, 0x3c} // 77 w
,{0x44, 0x28, 0x10, 0x28, 0x44} // 78 x
,{0x0c, 0x50, 0x50, 0x50, 0x3c} // 79 y
,{0x44, 0x64, 0x54, 0x4c, 0x44} // 7a z
,{0x00, 0x08, 0x36, 0x41, 0x00} // 7b {
,{0x00, 0x00, 0x7f, 0x00, 0x00} // 7c |
,{0x00, 0x41, 0x36, 0x08, 0x00} // 7d }
,{0x10, 0x08, 0x08, 0x10, 0x08} // 7e ←
,{0x78, 0x46, 0x41, 0x46, 0x78} // 7f →

void LcdCharacter(char character)
  LcdWrite(LCD_D, 0x00);
  for (int index = 0; index < 5; index++)
    LcdWrite(LCD_D, ASCII[character - 0x20][index]);
  LcdWrite(LCD_D, 0x00);

void LcdClear(void)
  for (int index = 0; index < LCD_X * LCD_Y / 8; index++)
    LcdWrite(LCD_D, 0x00);

void LcdInitialise(void)
  pinMode(PIN_SCE, OUTPUT);
  pinMode(PIN_DC, OUTPUT);
  pinMode(PIN_SDIN, OUTPUT);
  pinMode(PIN_SCLK, OUTPUT);
  digitalWrite(PIN_RESET, LOW);
  digitalWrite(PIN_RESET, HIGH);
  LcdWrite(LCD_C, 0x21 );  // LCD Extended Commands.
  LcdWrite(LCD_C, 0xB1 );  // Set LCD Vop (Contrast).
  LcdWrite(LCD_C, 0x04 );  // Set Temp coefficent. //0x04
  LcdWrite(LCD_C, 0x14 );  // LCD bias mode 1:48. //0x13
  LcdWrite(LCD_C, 0x0C );  // LCD in normal mode.
  LcdWrite(LCD_C, 0x20 );
  LcdWrite(LCD_C, 0x0C );

void LcdString(const char characters[])

void LcdString(char* characters){
  while (*characters)

void LcdWrite(byte dc, byte data)
  digitalWrite(PIN_DC, dc);
  digitalWrite(PIN_SCE, LOW);
  shiftOut(PIN_SDIN, PIN_SCLK, MSBFIRST, data);
  digitalWrite(PIN_SCE, HIGH);

void setup(void)
{ delay(1000);
   keyboard.begin(DataPin, IRQpin);
  LcdString("Hello World!");

void loop(void)
  if (keyboard.available()) {
    // read the next key
    char c =;
    // check for some of the special keys
    if (c == PS2_ENTER) {
    } else if (c == PS2_TAB) {
    } else if (c == PS2_ESC) {
    } else if (c == PS2_PAGEDOWN) {
    } else if (c == PS2_PAGEUP) {
    } else if (c == PS2_LEFTARROW) {
    } else if (c == PS2_RIGHTARROW) {
    } else if (c == PS2_UPARROW) {
    } else if (c == PS2_DOWNARROW) {
    } else if (c == PS2_DELETE) {
    } else {
      // otherwise, just print all normal characters

First as pointed out, this:
int ledlight = 13
Should be this:
int ledlight = 13;

Secondly this:
Should be this:

Finally, you cant use this:
void LcdString(char* characters){
  while (*characters)
with constant string literals. You have to have a seperate function to handle them. Fortunately C++ can handle overloaded function calls where you have two functions with the same name, but take different parameters/variables in the call. So lets overload LcdString and add the ability to add constant strings (the clue is in the name: const)
Lets add this:
void LcdString(const char characters[])
Which takes the constant string and type casts it to the non constant version. Of course this can be achieved with a simple type cast as such:
But it makes the code less messy to have a seperate function.
958  Using Arduino / General Electronics / Re: Components designated "SK"? on: October 07, 2012, 02:15:24 pm
Could you post a picture?
959  Using Arduino / Programming Questions / Re: How to enable the External Occillation. on: October 07, 2012, 10:58:16 am
It won't go much beyond 20MHz.

I tried running an atmega1284 at 24MHz (bought the wrong crystal by mistake) and while it ran, anything that tries to use the SRAM for more than a couple of bytes causes it to crash.

If you want a faster processor, get a Due (when it comes out) or an atxmega chip (someone made a core for them i think).
960  Using Arduino / Displays / Re: Nokia LCD display shield question on: October 07, 2012, 10:17:30 am
Just so you know, this:
Will take an awfully long time to execute as the display is only 128x128 and you are trying to print a box 6101 pixels square (starting at (0,0) ending at (6100,6100)).
If you just want to clear the screen, you can use this:
Which will set all pixels to be the background colour

Secondly, and most importantly, the Ethernet sheild uses pin 13 and pin 11.
What I did with my LCD shield is to cut the traces going to these pins and added jumper wires to pin 7 and pin 6. The you would just have to change your code to be:
const char Clk = 7;
const char Data = 6;
I found sparkfuns choice to use the SPI pins for this display rather unhelpful as we cant use the hardware SPI for it anyway (it uses a funny 9 bit SPI communication).

As a couple of side notes, but not related to your problem:

You can get rid of that White bar at the top of the screen by correctly setting the screen offset coordinate. The begin function is specified as: begin(xOffset, yOffset, InvertColour, Driver);
So by the looks of things, your screen (unlike mine) is perfectly aligned at the origin, so to get rid of those two pixels, change this:

Changes to:

You can also now use predefined colours for easy reading:
graphic.setForeColour(15,15,15); //While this is perfectly acceptable...
graphic.setForeColour(GLCD_WHITE); //This does the same thing, but is easier to follow
You don't have to use these colours and the way you are doing it will work absolutely fine, but based on the the comments next to setting colours in your code, it may be easier to read.
This is a full list of colours defined in the header file.
#define GLCD_WHITE 0x0F0F0F
#define GLCD_BLACK 0x000000
#define GLCD_GREEN 0x000F00
#define GLCD_LIME 0x080F00
#define GLCD_BLUE 0x00000F
#define GLCD_RED 0x0F0000
#define GLCD_GREY 0x080808
#define GLCD_ORANGE 0x0F0800
#define GLCD_CYAN 0x000F0F
#define GLCD_YELLOW 0x0F0F00
#define GLCD_LEMON 0x0F0F08
#define GLCD_MAGENTA 0x0F000F
#define GLCD_PINK 0x0F0808
Pages: 1 ... 62 63 [64] 65 66 ... 110