Show Posts
Pages: [1] 2 3 ... 252
1  Using Arduino / Programming Questions / Re: Debouncing Touch Screen on: September 19, 2014, 10:10:15 pm
To debounce a touch screen you take the average of however many samples you want. The more samples you take that more precise the touch point will be, but the slower it will be too.
2  Development / Other Software Development / Re: Some new core functions on: September 19, 2014, 03:59:24 pm
Quote
No, its a bug, you need to use a large enough type for the sum so it doesn't overflow,
so if the array elements are int16, the sum should be int32, etc etc.  I'm not sure
templates can do what's needed.
Ok but what if someone (for whatever reason) wants to find the mean of values that are Absurdly big, like type long long . What do I do then, make tmp long double? Should I cut them off at type long or float, and prompt, Hey, your values are too big!

I suppose I can use a struct and automatically set tmp to the next type, so if the user enters int, the compiler will make tmp long or float.
3  Using Arduino / Project Guidance / Re: Want to make Arduino talk back to me. on: September 19, 2014, 08:00:56 am
Others have made these libraries using their smart phones and then based on the response, the phone would send the corresponding command to the arduino. I have never gotten into this or even tried to do it (yet), so I do not know what kind of preexisting software there is to make a custom speech library. There is however an app called BT Voice Control for Android that can send strings to an Arduino which then needs to be told what to do when a certain string comes in.
4  Development / Other Software Development / Re: Updated Wii Classic Controller Library on: September 18, 2014, 06:31:24 pm
Apparently the last library had a compiling flaw with the new functions. I really don't what happened, I will post the fixed version.
5  Using Arduino / Programming Questions / Re: Compiler warning when using F() macro on: September 18, 2014, 03:18:05 pm
What IDE version are you using? I'm using 1.0.5-r2 and I don't get that warning message.

With 1.5.7, I get this:
Quote
Sketch uses 1,854 bytes (5%) of program storage space. Maximum is 32,256 bytes.
Global variables use 188 bytes (9%) of dynamic memory, leaving 1,860 bytes for local variables. Maximum is 2,048 bytes.
6  Using Arduino / Programming Questions / Re: Get Keypad sketch working? on: September 18, 2014, 01:51:36 pm
Is myKeypad.getKey() returning a value between 0 - 9 or 48 - 56? In the serial it shows 0 - 9, but in reality it is just showing the character '0' - '9' and if you look at an Ascii table, those characters correspond to 48(0) - 56(9)
7  Using Arduino / Programming Questions / Re: How can I split a String or a Char on: September 18, 2014, 11:12:45 am
So use an IF ELSE statement and go through each character individually. If the character is a " then skip over it, otherwise print the rest.
8  Using Arduino / Programming Questions / Re: How can I split a String or a Char on: September 18, 2014, 08:19:57 am
Quote
+CMGR: "REC READ","55555","","13/09/08,14:25:34+08"
If this is what you want to split up, then look into strtok(), it is a very useful function.
9  Development / Other Software Development / Re: Some new core functions on: September 17, 2014, 07:48:56 pm
Quote
1)  tmp can (and with 16 bit ints, often will) overflow, leading to nonsense result.
There will always be some kind of overflow, even if you make the array an unsigned 64 bit type and set all the elements to the maximum 64 bit value (1.8446744e+19).

Quote
2) if N is integer type then the calculation tmp/N truncates, rather than rounds,
which is biased.
Fair enough

Quote
3) Divide by zero if N = 0
When will this happen? Does myArray[0] even get compiled, regardless of type?

Quote
and why is x is passed by reference, or is that a templates thing?
I just did it for consistency with the other functions.
10  Using Arduino / Displays / Re: Arduino 1.8" TFT screen cannot work on: September 17, 2014, 03:51:55 pm
Quote
I bought Arduino 1.8" TFT screen few mouths before
Is that a few mouths measured by height or width?
I too had an issue with my 1.8" TFT when I first got it, I followed the wiring diagram that came with it and nothing worked. Then with a little common sense, I found out it was just a wiring issue, but on their end.

Try this sketch.
Code:
// Pins SCLK and MOSI are fixed in hardware, and pin 10 (or 53)
// must be an output
//#define sclk/SCL 13    // for MEGAs use pin 52
//#define mosi/SDA 11    // for MEGAs use pin 51
#define cs 10   // for MEGAs you probably want this to be pin 53
#define dc 9
#define rst 8  // you can also connect this to the Arduino reset

// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0 
#define WHITE           0xFFFF

#include <ST7735.h>
#include <SPI.h>

// Option 1: use any pins but a little slower
//ST7735 tft = ST7735(cs, dc, mosi, sclk, rst); 

// Option 2: must use the hardware SPI pins
// (for UNO thats sclk = 13 and sid = 11) and pin 10 must be
// an output. This is much faster - also required if you want
// to use the microSD card (see the image drawing example)
ST7735 tft = ST7735(cs, dc, rst);   

void fillpixelbypixel(uint16_t color) {
  for (uint8_t x=0; x < tft.width; x++) {
    for (uint8_t y=0; y < tft.height; y++) {
      tft.drawPixel(x, y, color);
    }
  }
  delay(100);
}

void setup(void) {
  Serial.begin(115200);
  Serial.print("hello!");
  tft.initR();               // initialize a ST7735R chip

  Serial.println("init");
  tft.writecommand(ST7735_DISPON);
 
  uint16_t time = millis();
  tft.fillScreen(BLACK);
  time = millis() - time;
 
  Serial.println(time, DEC);
  delay(500);
 
  //
  tft.fillScreen(BLACK);
  testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", WHITE);
  delay(10000);
 
  //a single pixel
  tft.drawPixel(tft.width/2, tft.height/2, GREEN);
  delay(500);
 
  // line draw test
  testlines(YELLOW);
  delay(500);   
 
  // optimized lines
  testfastlines(RED, BLUE);
  delay(500);   

  testdrawrects(GREEN);
  delay(500);

  testfillrects(YELLOW, MAGENTA);
  delay(500);

  tft.fillScreen(BLACK);
  testfillcircles(10, BLUE);
  testdrawcircles(10, WHITE);
 
  Serial.println("done");
  delay(1000);
}

void loop() {
  tft.writecommand(ST7735_INVON);
  delay(500);
  tft.writecommand(ST7735_INVOFF);
  delay(500);
}

void testlines(uint16_t color) {
   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width; x+=6) {
     tft.drawLine(0, 0, x, tft.height-1, color);
   }
   for (uint16_t y=0; y < tft.height; y+=6) {
     tft.drawLine(0, 0, tft.width-1, y, color);
   }
   
   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width; x+=6) {
     tft.drawLine(tft.width-1, 0, x, tft.height-1, color);
   }
   for (uint16_t y=0; y < tft.height; y+=6) {
     tft.drawLine(tft.width-1, 0, 0, y, color);
   }
   
   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width; x+=6) {
     tft.drawLine(0, tft.height-1, x, 0, color);
   }
   for (uint16_t y=0; y < tft.height; y+=6) {
     tft.drawLine(0, tft.height-1, tft.width-1, y, color);
   }

   tft.fillScreen(BLACK);
   for (uint16_t x=0; x < tft.width; x+=6) {
     tft.drawLine(tft.width-1, tft.height-1, x, 0, color);
   }
   for (uint16_t y=0; y < tft.height; y+=6) {
     tft.drawLine(tft.width-1, tft.height-1, 0, y, color);
   }
   
}

void testdrawtext(char *text, uint16_t color) {
  tft.drawString(0, 0, text, color);
}

void testfastlines(uint16_t color1, uint16_t color2) {
   tft.fillScreen(BLACK);
   for (uint16_t y=0; y < tft.height; y+=5) {
     tft.drawHorizontalLine(0, y, tft.width, color1);
   }
   for (uint16_t x=0; x < tft.width; x+=5) {
     tft.drawVerticalLine(x, 0, tft.height, color2);
   }
}

void testdrawrects(uint16_t color) {
 tft.fillScreen(BLACK);
 for (uint16_t x=0; x < tft.width; x+=6) {
   tft.drawRect(tft.width/2 -x/2, tft.height/2 -x/2 , x, x, color);
 }
}

void testfillrects(uint16_t color1, uint16_t color2) {
 tft.fillScreen(BLACK);
 for (uint16_t x=tft.width-1; x > 6; x-=6) {
   tft.fillRect(tft.width/2 -x/2, tft.height/2 -x/2 , x, x, color1);
   tft.drawRect(tft.width/2 -x/2, tft.height/2 -x/2 , x, x, color2);
 }
}

void testfillcircles(uint8_t radius, uint16_t color) {
  for (uint8_t x=radius; x < tft.width; x+=radius*2) {
    for (uint8_t y=radius; y < tft.height; y+=radius*2) {
      tft.fillCircle(x, y, radius, color);
    }
  } 
}

void testdrawcircles(uint8_t radius, uint16_t color) {
  for (uint8_t x=0; x < tft.width+radius; x+=radius*2) {
    for (uint8_t y=0; y < tft.height+radius; y+=radius*2) {
      tft.drawCircle(x, y, radius, color);
    }
  } 
}
11  Using Arduino / Programming Questions / Re: Irregular time on: September 16, 2014, 03:17:11 pm
Decrease by 1, 5, 100? Do they decrease until they reach 0, or just roll over?

Quote
loop;
not needed, and missing something. the loop() function does exactly what its name implies, it loops forever...or at least until the power is turn off or is caught in another inescapable loop.

Have you tried adding in a counter that increase as the loop() function, loops?

f(5200 - some_variable);
.
.
.
some_variable++; // some_variable += 5; some_variable += 10; ... etc
12  Using Arduino / Project Guidance / Re: Working with RF Module on: September 16, 2014, 10:13:25 am
The VirtualWire library does the encoding and decoding for the module I suggested, and Yes, yours already does the en/decoding.
So, now what you need to do is basically all the work of converting the values to bits and send them out, then regroup them on the other side.

Which is why I first suggested you use bitRead() of the values you want to send and then send the bits out. However, now you need to regroup those bits back together with bitWrite to be usable for your project.
13  Using Arduino / Project Guidance / Re: Working with RF Module on: September 16, 2014, 08:09:48 am
Well then, that is not the correct RF module to use. You should have gotten this.
433 Mhz RF pair
14  Using Arduino / Project Guidance / Re: Working with RF Module on: September 15, 2014, 10:34:43 am
These RF modules are "Simple" meaning they do their own decoding and what you send is what you get. If you want to send two analog signals, you would need to use bitRead() to read the bits in the integer from analogRead() value. Then just send those bits out to the transmitter.
15  Using Arduino / Programming Questions / Re: Arexx AAR Robot need help on: September 15, 2014, 09:23:21 am
Have you download the library, Yes or No?
Pages: [1] 2 3 ... 252