Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: code compiling, but will not actually work on: May 18, 2014, 03:05:04 pm
Yes.
 Also it does not write to the sd card either.
2  Using Arduino / Programming Questions / code compiling, but will not actually work on: May 18, 2014, 02:40:13 pm
Hello, all
Overview of the project: Using a toy EEG, this device is supposed to help me wake up at the best time in the morning (ie in light sleep)
Overview of he problem: Although each of the small parts of the code worked separately, when I put them all together it compiles but does not work. If you look in the void setup, once the code is started up it should print out "Initializing SD card..." to the serial monitor. It does not do that. Nor does it print out to the Bluetooth console.

Details of the project:  There are a few simple functions.
playTone: takes in a pin and plays a tone on the piezo. This has been tested and works successfully

addValue: this function adds a new value into the array by removing the oldest one and shifting all the others over one. This too works alone

isAwake: this function finds the average of the array if it is equal to or greater than the input tolerance it returns a boolean based on the result of the computation. This also works alone

In the void setup you will see the whole setup for getting the time up and running. An android app sends the current time and the desired wake up range to the arduino in bytes. In the void setup there is a while true that waits for this processs to be finished.
After that process the array is populated with the first 120 packets. but these parts of the setup are not really significant because I believe the error occurs before hand, because the serial monitor is not printing out the messege
Code:
#include "pitches.h"
#include <SD.h>
#include <Brain.h>
#include <Time.h>
#include <SoftwareSerial.h>
const int sampleSize=120; // the amount of packets needed to start actual computation
const int chipSelect = 4;
const long tolerance = 55000;//lowest amplitude for light sleep
SoftwareSerial blue(9,10); //nein- connect the bluetooth to 9, 10.
int data;
// The next few variables are for the alarm feature
int counter=0;
String setH;
String setMinutes;
String setSeconds;
String minHour;
String minMinute;
String maxHour;
String maxMinute;
long brain_data[sampleSize];
Brain brain(Serial);
// this function plays a piezo buzzer at the given pin
void playTone(int pin){
    int melody[] = { NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
    int noteDurations[] = {4, 8, 8, 4,4,4,4,4 };
    for (int thisNote = 0; thisNote < 8; thisNote++) {
    int noteDuration = 1000/noteDurations[thisNote];
    tone(pin, melody[thisNote],noteDuration);
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    noTone(pin);
  }
 
}
//this function adds a value to the global array, it deletes the last one and moves all the others over one
void  addValue(int number){
   for (int i=sampleSize-1; i>=1; i--){
    brain_data[i] = brain_data[i-1];
  }

   brain_data[0]=number;
 
 
}
// this function takes in a tolerance,and finds the average of the global array. If the average is bigger than the tolerance the user is in light sleep and the function returns true
boolean isAwake(long tolerance){
  long sum = 0;
  for (int i = 0; i < sampleSize; i++){
    sum += brain_data[i];
  }
  long average = sum / sampleSize;
  if (average >= tolerance){
    return true;
  }
  else return false;
}

void setup()
{
  Serial.begin(9600);
  blue.begin(9600);
 
  Serial.print("Initializing SD card..."); //so this is where the error occurs. This does not print out.
  pinMode(10, OUTPUT);
 
 
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    return;
  }
  Serial.println("card initialized.");
  int i = 0;
  while (true){
  if (blue.available()){
   if (counter<2){
     int num= (int)blue.read()-48;
     setH+=(String)num;
     counter++;
   }
   else if (1<counter && counter<4){
     int num= (int)blue.read()-48;
      setMinutes+= (String)num;
      counter++;
   }
   else if (3<counter && counter<6){
      int num= (int)blue.read()-48;
      setSeconds+=(String)num;
      counter++;
   }
  else if (5<counter && counter<8){
     int num= (int)blue.read()-48;
     minHour+=(String)num;
     counter++;
  }
   else if (7<counter && counter<10){
     int num= (int)blue.read()-48;
     minMinute+=(String)num;
     counter++;
  }
  else if (9<counter && counter<12){
     int num= (int)blue.read()-48;
     maxHour+=(String)num;
     counter++;
  } 
  else {
    int num= (int)blue.read()-48;
     maxMinute+=(String)num;
     counter++;
  }
  }
 if (counter>=14){
  break;
 }
 }
  setTime(setH.toInt(),  setMinutes.toInt(), setSeconds.toInt(), 1, 1, 11);
  Serial.println("Wake up minimum time " + minHour+":"+ minMinute);
  Serial.println("Wake up maximum time " + maxHour+":"+maxMinute);
  while ( i<=sampleSize){
   if (brain.update()){
      addValue((long)brain.readDelta()) ;
       Serial.println(brain.readDelta());
       i++;
   }
 }
}


void loop()
{
  time_t t=now(); //time now
  // make a string for assembling the data to log:
  String dataString = "...";


  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
 
 
  if (brain.update()){
    dataString = brain.readCSV();
    addValue((long)brain.readDelta());
    if (hour(t)== minHour.toInt()){
     if(minute(t) >= minMinute.toInt()){
       if(isAwake(tolerance)){
         playTone(8);
         dataString += "WOKE UP";
         dataString += hour(t);
         dataString += minute(t);
       }                 
     }
    }
    else if(hour(t)==maxHour.toInt()){
      if(minute(t)<=maxMinute.toInt()){
        if(isAwake(tolerance)){
         playTone(8);
         dataString += "WOKE UP";
         dataString += hour(t);
         dataString += minute(t);
       }
      }
    }
  }
  // if the file is available, write to it:
  if (dataString.length() > 5){
    File dataFile = SD.open("brain2.txt", FILE_WRITE);
    if (dataFile) {
      dataFile.println(dataString);
      dataFile.close();
      // print to the serial port too:
      Serial.println(dataString);
    } 
    // if the file isn't open, pop up an error:
    else {
      Serial.println("error opening datalog.txt");
    }
  }
  //delay(1000);
}

3  Using Arduino / Programming Questions / Re: making a function that will update and array on: May 08, 2014, 03:08:59 pm
Hello all,
Thanks for the responses.
So I redid the function so it uses the global variable of the array.
The problem is when I print out the new array, all the values are 17424 except the first one which is 500

Code:
long brain_data[30]={82960, 21827, 39586, 34202, 47124, 69690, 9468, 47798, 6563, 47456, 42494, 66574, 92910, 19151, 23587, 155965, 45245, 33233, 23437, 22788, 168338, 4015, 20487, 44382, 8065, 85082, 5408, 147608, 109213, 109210};

void  addValue(int number){
   for (int i=0; i<29; i++){
    int array_val;
    array_val=brain_data[i];
    brain_data[i+1]=array_val;
   }
   brain_data[0]=number;
  
  
}
void setup()
{
  Serial.begin(9600);
 addValue(500);
 for (int i=0; i<30; i++)
 {
  Serial.println(brain_data[i]);
 }
}
void loop(){
  
}
4  Using Arduino / Programming Questions / making a function that will update and array on: May 07, 2014, 11:23:03 pm
Hello all,
 So I am not too familiar with using arrays with C
But basically what I want to do is have a function where I can pass in a value and a filled array and move every value over one, throw out the last one and put a new value in the beginning.
I do not really understand the whole * thing in c, but I have seen it around, I am not sure if I need to do it to get this function to work properly.
Code:
int brain_data[30]={82960, 21827, 39586, 34202, 47124, 69690, 9468, 47798, 6563, 47456, 42494, 66574, 92910, 19151, 23587, 155965, 45245, 33233, 23437, 22788, 168338, 4015, 20487, 44382, 8065, 85082, 5408, 147608, 109213, 109210};

int * addValue(int number , int array[]){
   for (int i=0; i<29; i++){
    int array_val;
    array_val=array[i];
    array[i+1]=array_val;
   }
   array[0]=number;
   return array;
 
}
void setup()
{
  Serial.begin(9600);
 Serial.println(addValue(500, brain_data));
}
void loop(){
 
}

This code returns the following error:
Code:
call of overloaded 'println(int*) is ambiguous


5  Using Arduino / Programming Questions / Writing to an SD card works fine with an Uno but not with a Micro on: March 26, 2014, 03:13:27 pm
We were able to successfully write to an SD card (using SD.h), but it doesn't work with an Arduino Micro.
Here's the code we are using:
Code:
/*
  SD card datalogger
 
 This example shows how to log data from three analog sensors
 to an SD card using the SD library.
 
 The circuit:
 * analog sensors on analog ins 0, 1, and 2
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 
 created  24 Nov 2010
 modified 9 Apr 2012
 by Tom Igoe
 
 This example code is in the public domain.
 
 */

#include <SD.h>

// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 7;

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
  pinMode(chipSelect, OUTPUT);
 
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}

void loop()
{
  // make a string for assembling the data to log:
  String dataString = "hi this is a test";



  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("log.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  } 
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening log.txt");
  }
}
6  Using Arduino / Programming Questions / Is there interference between microsd card (SD library) and the brain library? on: March 13, 2014, 11:33:07 am
I have a very similar  problem as this guy http://forum.arduino.cc/index.php?topic=107334.0 ; however, it does not look like that was solved.
Project: I want to use an arduino to connect a toy eeg and log all of the data to a micro sd card. I am using the eeg from this tutorial http://frontiernerds.com/brain-hack . It works perfectly on it's own. I am using a microSD card with a simple breakout from sparkfun https://www.sparkfun.com/products/544. It also works perfectly on it's own

Problem: When I try to merge both of them together, it does not work. I have narrowed the problem down to one thing. On the eeg module, when the code calls brain.update() it returns false and not true.
BTW eeg returns a char, in my code a casted it to a string
So I think there is something in these libraries that are conflicting with each other, I am just not sure what.

 Code for just the eeg (example from the library)
Code:
// Arduino Brain Library - Brain Serial Test

// Description: Grabs brain data from the serial RX pin and sends CSV out over the TX pin (Half duplex.)
// More info: https://github.com/kitschpatrol/Arduino-Brain-Library
// Author: Eric Mika, 2010 revised in 2014

#include <Brain.h>

// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);

void setup() {
    // Start the hardware serial.
    Serial.begin(9600);
}

void loop() {
    // Expect packets about once per second.
    // The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:
    // "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"   
    if (brain.update()) {
        Serial.println(brain.readErrors());
        Serial.println(brain.readCSV());
    }
}

Code with just the SD card also just example
Code:
/*
  SD card datalogger
 
 This example shows how to log data from three analog sensors
 to an SD card using the SD library.
 
 The circuit:
 * analog sensors on analog ins 0, 1, and 2
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 
 created  24 Nov 2010
 modified 9 Apr 2012
 by Tom Igoe
 
 This example code is in the public domain.
 
 */

#include <SD.h>

// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.
const int chipSelect = 10;

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }


  Serial.print("Initializing SD card...");
  // make sure that the default chip select pin is set to
  // output, even if you don't use it:
  pinMode(10, OUTPUT);
 
 
  // see if the card is present and can be initialized:
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    // don't do anything more:
    return;
  }
  Serial.println("card initialized.");
}

void loop()
{
  // make a string for assembling the data to log:
  String dataString = "This is a test. Jacob stein ";


  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  File dataFile = SD.open("datalog.txt", FILE_WRITE);

  // if the file is available, write to it:
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
    // print to the serial port too:
    Serial.println(dataString);
  } 
  // if the file isn't open, pop up an error:
  else {
    Serial.println("error opening datalog.txt");
  }
}

Combined code, modified for debugging. It returns "the head does not work" but it successfully writes to the micro sd card.
Code:
#include <SD.h>
#include <Brain.h>
Brain brain(Serial);
const int chipSelect = 10;
String dataToWrite;


void setup(){
  Serial.begin(9600);
  Serial.println("Initializing SD...");
  pinMode(chipSelect,OUTPUT);
  if (!SD.begin(chipSelect)){
    Serial.println("Card failed!!!");
    return;
  }
  Serial.println("Card Initialized.");
}

void loop(){
  if (brain.update()) {
        Serial.println(brain.readErrors());
        Serial.println(brain.readCSV());
    }
    else
   
    {
     
     Serial.println("The Head does not work");
    }
  File dataFile = SD.open("testtest.txt",FILE_WRITE);
  if(dataFile ){
   
    dataFile.println("hello");
    dataFile.close();
    Serial.print("Wrote to the SD: ");
    Serial.println("hello");
    }
  else{
    Serial.println("Couldn't make file!!!");
  }
delay(2000);
}

Earlier I had one if statement check if( brain.update() && dataFile) and then add the  brain.readcsv() to the file. It wouldnt go into the body of the if statement though.
7  Using Arduino / Project Guidance / Re: Making a game controller using the Arduino uno on: June 25, 2013, 02:00:29 pm
I am using this shield https://www.sparkfun.com/products/9760
8  Using Arduino / Project Guidance / Making a game controller using the Arduino uno on: June 24, 2013, 02:14:38 pm
Hello all
I am looking to create a game controller using the arduino, a joystick shield (from sparkfun), and a bluetooth dongle (also from sparkfun). I am sort of lost on how to do get the bluetooth dongle on the arduino to output something. I want it to output a button press, sort of simulate an actual keyboard. Would anyone know of any good tutorials?
9  Using Arduino / Programming Questions / processing for arduino on: January 21, 2013, 10:21:24 am
Hi
does anyone know any good tutorials for processing for the arduino?
10  Using Arduino / Project Guidance / Arduino and Android on: January 17, 2013, 04:00:16 pm
Hi
Does anyone know how to have an android device communicate with the arduino? Any good tutorials? Is the android IOIO  a better choice?
I want to push notifications (IE, texts, emails, phone calls, alarms, calanders everts etc. from the my android to my anrduino via bluetooth. With that information I want to be able to control an led.
The main part that I need guidance on is the pushing over the notifications.
Does anyone know how to do this?
11  Using Arduino / Programming Questions / map () and Constraint() on: January 13, 2013, 03:22:52 pm
Hi all, i have a question about the map function; why does it not map somethings? In the arduino reference it says
Quote
Does not constrain values to within the range, because out-of-range values are sometimes intended and useful. The constrain() function may be used either before or after this function, if limits to the ranges are desired.
Is it random?( does it randomly not map certain values)?
In essence my question is what is the point of having a separate map and constrain function?
Maybe i do not understand exactly what they do; please explain.
12  Using Arduino / Programming Questions / Re: Code help on: October 09, 2012, 06:49:15 pm
Hello again, I really appreciate all your help and  I am sorry that I can not do this by myself.
Just to clear things up, I believe my current problem started once i started the double array. I reread all the corrections and I placed them in.
Here is my error, again
Quote
Lcd_screen___keyboard:16: error: expected constructor, destructor, or type conversion before '=' token
Lcd_screen___keyboard:17: error: expected constructor, destructor, or type conversion before '=' token
Lcd_screen___keyboard:19: error: 'c' was not declared in this scope
Lcd_screen___keyboard.cpp: In function 'void setup()':
Lcd_screen___keyboard:180: error: invalid conversion from 'const char*' to 'char'
Lcd_screen___keyboard:180: error: initializing argument 1 of 'void LcdCharacter(char)'
Lcd_screen___keyboard.cpp: In function 'void loop()':
Lcd_screen___keyboard:194: error: invalid conversion from 'const char*' to 'char'
Lcd_screen___keyboard:194: error: initializing argument 1 of 'void LcdCharacter(char)'
Lcd_screen___keyboard:198: error: 'LCDString' was not declared in this scope

Here is my code corrected and updated
Code:
#define PIN_SCE   7
#define PIN_RESET 6
#define PIN_DC    5
#define PIN_SDIN  4
#define PIN_SCLK  3

#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;
two_character_string[0] = c;
two_character_string[1] = 0;

char two_character_string[2] = {c, 0};

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 gotoXY(int x, int y) {
  LcdWrite(0, 0x80 | x);  // Column.
  LcdWrite(0, 0x40 | y);  // Row.  ?
}

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 ) ; index++)
    LcdWrite(LCD_D, 0x00);
   
  gotoXY(0, 0); //After we clear the display, return to the home position
}


void LcdInitialise(void)
{
  pinMode(PIN_SCE, OUTPUT);
  pinMode(PIN_RESET, 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[])
{
  LcdString((char*)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)
{
   keyboard.begin(DataPin, IRQpin);
  LcdInitialise();
LCDClear();
   LcdCharacter("Ready!");
}

void loop(void)
{ LCDClear();
  if (keyboard.available()) {
   
    // read the next key
    char c = keyboard.read();
   
    // check for some of the special keys
    if (c == PS2_ENTER) {
     
    } else if (c == PS2_TAB) {
       LcdCharacter("[Tab]");
    }  else {
     

       LCDString(two_character_string);
    }
 


}
}

The error highlights ; this two_character_string[0] = c; in the code
13  Using Arduino / Programming Questions / Re: Code help on: October 07, 2012, 04:52:31 pm
i still get the same error
14  Using Arduino / Programming Questions / Re: Nokia 5110 clear screen. on: October 07, 2012, 04:51:55 pm
 I was thinking about using a Do... While here to clear the screen at the right time, however how would I tell the arduino to clear the screen when it gets to the last pixel on the the last row? In my code gotoxy is the first pixel...
15  Using Arduino / Programming Questions / Re: Nokia 5110 clear screen. on: October 07, 2012, 03:57:15 pm
does not fix it, same problem. I was thinking maybe if I place  LcdClear(); in the loop it would work

UPDATE, putting it in the loop actually causes more problems, the text does not show up at all
Pages: [1] 2 3