Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Programming Questions / Passing defined arrays into function, variables not declared in scope on: April 11, 2013, 08:37:24 pm
Greetings,

I am having a lot of trouble passing arrays into functions. It keeps telling me that the arrays are not defined. They are in the setup() could someone tell me why?

Here are the errors:
BareMinimum.cpp: In function 'void loop()':
BareMinimum:20: error: 'Block_1' was not declared in this scope
BareMinimum:20: error: 'Block_2' was not declared in this scope
BareMinimum:20: error: 'Block_3' was not declared in this scope
BareMinimum:20: error: 'Block_4' was not declared in this scope

Here is the code:
Code:
void setup() {
  // put your setup code here, to run once:

#define Block_Size 16

#define S3_pin 53
#define S2_pin 51
#define S1_pin 49
#define S0_pin 47


int Block_1[Block_Size];
int Block_2[Block_Size];
int Block_3[Block_Size];
int Block_4[Block_Size];

}

void loop() {
  // put your main code here, to run repeatedly:
  CheckBlocks(Block_1, Block_2, Block_3, Block_4);
 
 
 
 
}

void CheckBlocks(int Block_1[], int Block_2[], int Block_3[], int Block_4[]){
  int quadrent = 0;
  for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       delay(1);
       Block_1[channel] = analogRead(A15);
  }// End for loop
  quadrent = 1;
  for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       delay(1);
       Block_1[channel] = analogRead(A14);
  }// End for loop ;
  quadrent = 2;
  for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       delay(1);
       Block_1[channel] = analogRead(A13);
  }// End for loop );
  quadrent = 3;
  for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       delay(1);
       Block_1[channel] = analogRead(A12);
  }// End for loop
}//end function
 
 



//This function activates the muxes
void set_channel(int channel) {
     switch(channel)
       {
        case 0:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 1:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 2:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 3:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 4:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 5:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 6:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 7:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
       case 8:   digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 9:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 10: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 11: digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH); 
                 break;
        case 12: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 13: digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 14: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 15: digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;       
        default: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);   
                 break;
                 }//end case
}//end function

17  Using Arduino / Programming Questions / Re: Passing and returning Arrays into functions on: April 09, 2013, 10:01:40 am
Thank you.

I understand now that I am suppost to give the compiler the size of the array via pointer. How do I output or return an array from a function?

Thanks

Bill
18  Using Arduino / Programming Questions / Passing and returning Arrays into functions on: April 08, 2013, 10:55:29 pm
I am trying to pass an array of binary numbers into a function and (eventually) have it return the updated array. I keep getting some errors I do not understand can someone tell me what to do? I have the function and inputs in the code (snippets where the errors are flagged) and the errors posted below

Cleverblocks_test_2.cpp: In function 'void loop()':
Cleverblocks_test_2:229: error: expected primary-expression before ']' token
Cleverblocks_test_2:229: error: expected primary-expression before ']' token
Cleverblocks_test_2:229: error: expected primary-expression before ']' token
Cleverblocks_test_2:229: error: expected primary-expression before ']' token
Cleverblocks_test_2.cpp: In function 'void CheckBlocks(int*, int*, int*, int*)':
Cleverblocks_test_2:257: error: expected primary-expression before ']' token
Cleverblocks_test_2:257: error: 'Bank1' was not declared in this scope
Cleverblocks_test_2:257: error: expected primary-expression before ']' token
Cleverblocks_test_2:259: error: expected primary-expression before ']' token
Cleverblocks_test_2:259: error: 'Bank2' was not declared in this scope
Cleverblocks_test_2:259: error: expected primary-expression before ']' token
Cleverblocks_test_2:261: error: expected primary-expression before ']' token
Cleverblocks_test_2:261: error: 'Bank3' was not declared in this scope
Cleverblocks_test_2:261: error: expected primary-expression before ']' token
Cleverblocks_test_2:263: error: expected primary-expression before ']' token
Cleverblocks_test_2:263: error: 'Bank4' was not declared in this scope
Cleverblocks_test_2:263: error: expected primary-expression before ']' token
Cleverblocks_test_2.cpp: In function 'int GetValues(int*, int)':
Cleverblocks_test_2:294: error: expected primary-expression before ']' token


Code:
void CheckBlocks(int Block_1[], int Block_2[], int Block_3[], int Block_4[]){
  int quadrent = 0;
  Block_1[] = GetValues(Bank1[], quadrent);
  quadrent = 1;
  Block_2[] = GetValues(Bank2[], quadrent);
  quadrent = 2;
  Block_3[] = GetValues(Bank3[], quadrent);
  quadrent = 3;
  Block_4[] = GetValues(Bank4[], quadrent);
}//end function
 
 


int GetValues(int Bank[], int quad){
    if (quadrent == 0){
      for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       int Analog_voltage = analogRead(A15);
       }//end for loop
       }// end if
    else if (quadrent == 1){
      for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       int Analog_voltage = analogRead(A14);
       }//end for loop
       }// end if
    else if (quadrent == 2){
      for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       int Analog_voltage = analogRead(A13);
       }//end for loop
       }// end if
    else {
      for(int channel= 0; channel < 16; channel++){
       set_channel(channel); // turns on channel
       int Analog_voltage = analogRead(A12);
       }//end for loop
       }// end if
       return Bank[];
}// end function

//timer1 interrupt 1Hz
ISR(TIMER5_COMPA_vect){
      for(int quadrent = 0; quadrent < 4; quadrent++){
       for(int channel= 0; channel < 16; channel++){
         
     }//second for loop
    }// first for loop 
 }//Interrupt

//This function activates the muxes
void set_channel(int channel) {
     switch(channel)
       {
        case 0:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 1:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 2:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 3:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 4:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 5:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 6:  digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
        case 7:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, LOW);
                 break;
       case 8:   digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 9:  digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 10: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 11: digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, HIGH); 
                 break;
        case 12: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 13: digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 14: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;
        case 15: digitalWrite(S0_pin, HIGH);
                 digitalWrite(S1_pin, HIGH);
                 digitalWrite(S2_pin, HIGH);
                 digitalWrite(S3_pin, HIGH);
                 break;       
        default: digitalWrite(S0_pin, LOW);
                 digitalWrite(S1_pin, LOW);
                 digitalWrite(S2_pin, LOW);
                 digitalWrite(S3_pin, LOW);   
                 break;
                 }//end case
}//end function


Thank you smiley
19  Using Arduino / Programming Questions / Using the MEGA's additional timers for interrupts on: April 07, 2013, 10:28:59 pm
Hello,

I am using a TFT touchscreen (Adafruit's one) and I am trying to implement a timer interrupt to run through several for loops once a second but the interrupts are (I think) being used for the touch screen. I am using the mega 2560 which has additional timers and I cannot figure out how to configure the timers to use them instead of timer0 timer1 timer2 which I believe the touch screen uses in the background. I am posting my code and the timers are included just below the header "Interrupts"

Please let me know what I need to change to use the additional timers in the MEGA
Code:
/*********************************************************************************************************
*                     Include Statements
/********************************************************************************************************/

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_TFTLCD.h> // Hardware-specific library
#include <TouchScreen.h>
#include <Timer.h>

/*********************************************************************************************************
*                     Define Statements
/********************************************************************************************************/
#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

//The min and max pixels of touch screen
#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0

// Assign human-readable names to some common 16-bit color values:
#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


#define S3_pin 53
#define S2_pin 51
#define S1_pin 49
#define S0_pin 47

#define E0_pin 45
#define E1_pin 43
#define E2_pin 41
#define E4_pin 39

Adafruit_TFTLCD tft;

#define BOXSIZE   100



/*********************************************************************************************************
*                     Varaible Declaration Statements
/********************************************************************************************************/
int Isready = 0; // ready to start building
int screen = 0; // selects the screen
int Analog_voltage; //Analog voltage read




/*********************************************************************************************************
*                     Arduino Setup Statements
*
/********************************************************************************************************/
void setup(void) {
  Serial.begin(9600);
 

/**********************************************************************************************************
*                    Turn on Timer ISR
***********************************************************************************************************/
cli();//stop interrupts

//set timer0 interrupt at 2kHz
  TCCR0A = 0;// set entire TCCR2A register to 0
  TCCR0B = 0;// same for TCCR2B
  TCNT0  = 0;//initialize counter value to 0
  // set compare match register for 2khz increments
  OCR0A = 124;// = (16*10^6) / (2000*64) - 1 (must be <256)
  // turn on CTC mode
  TCCR0A |= (1 << WGM01);
  // Set CS11 and CS10 bits for 64 prescaler
  TCCR0B |= (1 << CS11) | (1 << CS10);   
  // enable timer compare interrupt
  TIMSK0 |= (1 << OCIE0A);

//set timer1 interrupt at 1Hz
  TCCR1A = 0;// set entire TCCR1A register to 0
  TCCR1B = 0;// same for TCCR1B
  TCNT1  = 0;//initialize counter value to 0
  // set compare match register for 1hz increments
  OCR1A = 15624;// = (16*10^6) / (1*1024) - 1 (must be <65536)
  // turn on CTC mode
  TCCR1B |= (1 << WGM12);
  // Set CS12 and CS10 bits for 1024 prescaler
  TCCR1B |= (1 << CS12) | (1 << CS10); 
  // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);

//set timer2 interrupt at 8kHz
  TCCR2A = 0;// set entire TCCR2A register to 0
  TCCR2B = 0;// same for TCCR2B
  TCNT2  = 0;//initialize counter value to 0
  // set compare match register for 8khz increments
  OCR2A = 249;// = (16*10^6) / (8000*8) - 1 (must be <256)
  // turn on CTC mode
  TCCR2A |= (1 << WGM21);
  // Set CS11 bit for 8 prescaler
  TCCR2B |= (1 << CS11);   
  // enable timer compare interrupt
  TIMSK2 |= (1 << OCIE2A);


sei();//allow interrupts

// reset something?
  tft.reset();


  uint16_t identifier = tft.readID();


  tft.begin(identifier);


  pinMode(13, OUTPUT);
}

#define MINPRESSURE 10
#define MAXPRESSURE 1000


/*********************************************************************************************************
/                     Arduino Loop Statements
/*******************************************************************************************************/
void loop()
{
 
  digitalWrite(13, HIGH);// Get point on TFT board
  Point p = ts.getPoint();
  digitalWrite(13, LOW);

  // if sharing pins, you'll need to fix the directions of the touchscreen pins
  //pinMode(XP, OUTPUT);
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  //pinMode(YM, OUTPUT);

  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!

  if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
    Serial.print("\tPressure = "); Serial.println(p.z);

   
    // scale from 0->1023 to tft.width
    p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
 
    Serial.print("("); Serial.print(p.x);
    Serial.print(", "); Serial.print(p.y);
    Serial.println(")");
   //Setup Complete
   
   //Start Screen
   if (screen == 0){
     Isready = 0;
     tft.fillScreen(BLACK);
     tft.fillRect(20, 20, 200, 40, RED);
     tft.drawRect(20, 20, 200, 40, WHITE);
     tft.setCursor(30, 25);
     tft.setTextColor(WHITE);  tft.setTextSize(2);
     tft.println("START BULILDING");
   
     if (((20 < p.y) && (p.y < 60 )) && ((20 < p.x) && (p.x < 220))) {
       Serial.println("hello screen 0");
       screen  = 1;
       delay(100);
     }
     else{
       Serial.println("Not Red Button");
       
     }
  }
  else if (screen == 1){
     Isready = 1;
     tft.fillScreen(BLACK);
     tft.fillRect(20, 20, 200, 40, GREEN);
     tft.drawRect(20, 20, 200, 40, WHITE);
     tft.setCursor(40, 30);
     tft.setTextColor(WHITE);  tft.setTextSize(2);
     tft.println("  Ghost Block");
     
     tft.fillRect(20, 80, 200, 40, BLUE);
     tft.drawRect(20, 80, 200, 40, WHITE);
     tft.setCursor(40, 90);
     tft.setTextColor(WHITE);  tft.setTextSize(2);
     tft.println(" UnGhost Block");
     
     if (((20 < p.y) && (p.y < 60 )) && ((20 < p.x) && (p.x < 220))) {
       Serial.println("hello screen 1");
       screen  = 1;
       delay(100);
     }
     else if (((80 < p.y) && (p.y < 120 )) && ((20 < p.x) && (p.x < 220))) {
       Serial.println("hello screen 3");
       screen  = 0;
       delay(100);
     }
     else{
       Serial.println("Not green Button");
     }

     }// else if screen = 1
   
     
  }//If pressure is correct
 
}
//timer1 interrupt 1Hz
ISR(TIMER1_COMPA_vect){
      for(int quadrent = 0; quadrent < 4; quadrent++){
       for(int channel= 0; channel < 16; channel++){
         if (quadrent == 0){
            set_channel(channel); // turns on channel
            Serial.println(quadrent);
           
 
            int Analog_voltage = analogRead(A15);
           }
         else if (quadrent == 1){
           set_channel(channel); // turns on channel
           int Analog_voltage = analogRead(A14);
           Serial.println(quadrent);
           
           }
         else if (quadrent == 2){
           set_channel(channel); // turns on channel
           int Analog_voltage = analogRead(A13);
           Serial.println(quadrent);
           
           }
         else {
            set_channel(channel); // turns on channel
            int Analog_voltage = analogRead(A12);
            Serial.println(quadrent);
         
            delay(1000);
           }
     }//second for loop
    }// first for loop 
 }//Interrupt 
 
 

/*********************************************************************************************************
/                     Function Statements
/********************************************************************************************************/


Thanks for your time smiley
20  Using Arduino / Displays / 2.8" TFT touchscreen interrupts on: April 07, 2013, 05:25:31 pm
Is there a good way to use an interrupt on the TFT touchscreens? I have a for loop that takes up all the time so tht the controller cannot respond to the buttons on the screen. very troubling and could use some help

Thanks

Bill
21  Using Arduino / Displays / Denouncing a touchscreen button on: April 06, 2013, 11:39:58 pm
I have a 2.8" TFT LCD shield from ADAfruit industries and I've figured out how to create buttons at have them "Do stuff" but I am having a problem with Jitter in that all I am using so far is the delay(100); command to try and prevent any jitter. Sometimes it works and sometimes it does not. Any suggestions on how to improve this? The delays are highlighted below.

Thanks!

Code:
if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
    Serial.print("\tPressure = "); Serial.println(p.z);

   
    // scale from 0->1023 to tft.width
    p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
    p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
 
    Serial.print("("); Serial.print(p.x);
    Serial.print(", "); Serial.print(p.y);
    Serial.println(")");
   //Setup Complete
   
   //Start Screen
   if (screen == 0){
     Isready = 0;
     tft.fillScreen(BLACK);
     tft.fillRect(20, 20, 200, 40, RED);
     tft.drawRect(20, 20, 200, 40, WHITE);
     tft.setCursor(30, 25);
     tft.setTextColor(WHITE);  tft.setTextSize(2);
     tft.println("START BULILDING");
   
     if (((20 < p.y) && (p.y < 60 )) && ((20 < p.x) && (p.x < 220))) {
       Serial.println("hello screen 0");
       screen  = 1;
       
       delay(100);
     }
     else{
       Serial.println("Not Red Button");
       screen = 0;
     }
  }
  else if (screen == 1){
     Isready = 1;
     tft.fillScreen(BLACK);
     tft.fillRect(20, 20, 200, 40, GREEN);
     tft.drawRect(20, 20, 200, 40, WHITE);
     tft.setCursor(40, 30);
     tft.setTextColor(WHITE);  tft.setTextSize(2);
     tft.println("  Ghost Block");
     
     tft.fillRect(20, 80, 200, 40, BLUE);
     tft.drawRect(20, 80, 200, 40, WHITE);
     tft.setCursor(40, 90);
     tft.setTextColor(WHITE);  tft.setTextSize(2);
     tft.println(" UnGhost Block");
     
     Serial.println("running");
       
     }
   
     if (((20 < p.y) && (p.y < 60 )) && ((20 < p.x) && (p.x < 220))) {
       Serial.println("hello screen 1");
       screen  = 1;
       delay(100); // *****************// Here is the problem
     }
     else if (((80 < p.y) && (p.y < 120 )) && ((20 < p.x) && (p.x < 220))) {
       Serial.println("hello screen 3");
       screen  = 0;
       delay(100); // *****************// Here is the problem
     }
     else{
       Serial.println("Not green Button");
       screen = 1;
     }
  }
 
 if ((screen == 1) && (Isready == 1)){
    readAnalog_pin();
 }
22  Using Arduino / Project Guidance / COM-11102 Spark Fun Encoder Question on: March 04, 2013, 12:39:37 pm
Greetings,

I am building a hobby Coordinate Measuring Machine with four 1024 pulse rotary encoders from the spark fun website www.sparkfun.com item #11102. it is basically a four segment arm with no motor just encoders. I'm not really going into any reverse kinematics as my arm, hand and brain will be my feedback loop.

These devices output 1024 pulses per rotation. I will be using 4 of them. The regular arduino has a sampling rate of 15 khz do you think with hand motion (rpm max) that a regular Arduino UNO could keep up with these or do I need to use something like a DUE?

Also has anyone used that specific encoder before? Example code is always my best friend. Or has anyone ever attempted this?

Thanks !
23  Using Arduino / Displays / KS0108 on Duemoilanove on: September 23, 2012, 09:38:01 pm

Greetings I am having a great deal of trouble getting the KS0108 GLCD I purchased on Sparkfun about a year ago to work.
Here is the pinout for an standard Arduino Duemilanove (168/328).

The program below Which I have cut and pasted does not compile with the complaints listed below.
I have the ks0108.h installed in the libraries folder Which library should I use? I noticed there were several. THe LCD I have does not have any pin labels as well.

Any ideas?

Thanks

Code:
#include <ks0108.h>  // library header
#include <Arial14.h>  // font definition for 14 point Arial font.
#include "SystemFont5x7.h"   // system font
#include "ArduinoIcon.h"     // bitmap 
  unsigned long startMillis;
  unsigned int iter = 0;
void setup(){
  GLCD.Init(NON_INVERTED);   // initialise the library
  GLCD.ClearScreen(); 
  GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); //draw the bitmap at the given x,y position
  delay(3000);
  GLCD.ClearScreen();
  GLCD.SelectFont(System5x7);       // select fixed width system font
}
void loop(){ // run over and over again
  startMillis = millis();
  while( millis() - startMillis < 1000){ // loop for one second
    GLCD.DrawRect(0, 0, 64, 61, BLACK); // rectangle in left side of screen
    GLCD.DrawRoundRect(68, 0, 58, 61, 5, BLACK);  // rounded rectangle around text area   
    for(int i=0; i < 62; i += 4)
      GLCD.DrawLine(1,1,63,i, BLACK);  // draw lines from upper left down right side of rectangle 
    GLCD.DrawCircle(32,31,30,BLACK);   // draw circle centered in the left side of screen 
    GLCD.FillRect(92,40,16,16, WHITE); // clear previous spinner position 
    GLCD.CursorTo(5,5);               // locate curser for printing text
    GLCD.PrintNumber(++iter);         // print current iteration at the current cursor position
  }
  // display number of iterations in one second
  GLCD.ClearScreen();               // clear the screen 
  GLCD.CursorTo(13,2);              // positon cursor 
  GLCD.Puts("FPS= ");               // print a text string 
  GLCD.PrintNumber(iter);           // print a number
 }



\libraries\ks0108\ks0108.cpp: In member function 'void ks0108::Init(boolean)':
\libraries\ks0108\ks0108.cpp:505: error: 'OUTPUT' was not declared in this scope
\libraries\ks0108\ks0108.cpp:505: error: 'pinMode' was not declared in this scope
\libraries\ks0108\ks0108.cpp:511: error: 'delay' was not declared in this scope


It does not appear to like this function "DrawBitmap as it is not highlighted in yellow as the rest are

 GLCD.DrawBitmap(ArduinoIcon, 32,0, BLACK); //draw the bitmap at the given x,y position
24  Using Arduino / Programming Questions / Re: Help Getting Started with "Processing" on: May 26, 2011, 10:21:09 am
Here is what I am trying to do
http://luckylarry.co.uk/arduino-projects/arduino-modifying-a-robot-arm/
On page two there is a processing part

Thanks


25  Using Arduino / Programming Questions / Help Getting Started with "Processing" on: May 25, 2011, 11:21:08 pm
How do I get an arduino to work hand in hand with "Processing" ? I see the project arduino code alongside a Processing script. how do I install the software to get the two programs to work? Do I need to add-on to the arduino 21 release or download another program?

Thanks

26  Using Arduino / Networking, Protocols, and Devices / Bug in Arduino Ethernet shield when used with LCD on: May 08, 2011, 11:59:38 pm
This is the weirdest error I have ever encountered. On line 203 we call a web server function that sets up the Ethernet IP and Mac Address

void WebServerSetup()
{
  Ethernet.begin(mac, ip);
  server.begin();
}

This is called on line 391. These lines are somehow screwing up the LCD screen as it is now just printing
"fffffffff" across it. I believe there is something going on where 0X00 is being shared somewhere as 0x00 is in the mac address.

I have no idea what is going on here. If we remove the function the Ethernet doesn't work but the LCD works fine. With that function the LCD prints nothing but 'fffff' which is 111111111..... in Binary. If anyone has any idea what is going on here I am absolutely stumped

Thanks

The code is attached.
27  Using Arduino / Programming Questions / Re: Blinking without delay on: May 08, 2011, 03:44:25 pm
Here is the latest. The code compiles, the integers are all declared. If I comment out all the timing elements it works. I just cannot shut it off. however when I re-insert the code dealing with the timing aspect. Poof! it does not work.
Code:
else if((MiscMenu == 5) &&(buttonstate == LOW) && (TopMenuSelect == 0) ){
        if(automatic == false){
          unsigned long AutoMillis = millis();
          while(AutoMillis + (1 * OzMenu) < millis()) {
             if(automatic == false){ // Need t o add feedback
             digitalWrite(motorpin, HIGH);
             }//close actual feed
          }//close while
        }//close if automatic = true
        }//Close Else if statement
28  Using Arduino / Programming Questions / Re: Blinking without delay on: May 08, 2011, 03:06:48 pm
How would I go about calling it and not resetting the previous bookmark I took for millis()?
I'm really confused.
29  Using Arduino / Programming Questions / Re: Strange behaviour with incrementing pushbutton on: May 08, 2011, 03:05:30 pm
There is a "Button " library that someone wrote that works great for this. I had the same problem with noisy switches and it fixed it.
30  Using Arduino / Programming Questions / Re: Blinking without delay on: May 08, 2011, 02:56:05 pm
Breakfast and dinner are integers. They are from 1 to 23 in terms of hours.

Basically the think never turns off. Even past it's time.  Hypothetically lets say that millis() was 10,000. My interval was 8, multiplied by 1000 that gives 8000. So when millis() = 10,000 the output pin is high I add 10,000 to 8,000 (The duration) and then try to compare it the absolute up to date value of millis(). When the absolute value of millis() does in fact equal to 18,000 the output pin goes low.

I cannot figure out how to capture the current value of millis() to compare it to the value at which it should shout off.

Thanks for the replies I really appreciate it smiley

Bill
Pages: 1 [2] 3 4 ... 6