Show Posts
Pages: 1 ... 17 18 [19] 20 21 ... 244
271  Using Arduino / Programming Questions / Re: Compiling Errors trying to use the TFT-library on: July 16, 2014, 07:45:07 am
Where did you download that adafruit library, because I'm looking that the original library HERE, and see no such variable "newcolor" in this function, Adafruit_ST7735::Color565(uint8_t, uint8_t, uint8_t), in the library.

Could you post your full code.
272  Using Arduino / Programming Questions / Re: Array question on: July 16, 2014, 12:35:09 am
You don't have an index 12, so Red[12](blue and green too) is a random piece of memory. Your range is 0 - 11 and not 0 - 12
273  Using Arduino / Project Guidance / Re: Android tablet as keypad for RFID door entry on: July 15, 2014, 09:11:43 pm
Look in the Examples folder, its called Password.

My apologies, I did not update that sketch in a long time so it is using the old ITDB02 libraries, instead of the UTFT and UTouch libraries.

Here is the fixed version.
Code:

#include <Wire.h>
#include <UTouch.h>
#include <UTFT.h>
#include <TFT_Extension.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];
extern uint8_t BigFont[];
//myGLCD(RS,WR,CS,RST,ALE,mode);
UTFT myGLCD(ITDB32S,A1,A2,A0,A3,A5);   //
UTouch  myTouch(13,10,11,12,A4);
TFT_Extension myTFT(&myGLCD, &myTouch, LANDSCAPE);

char * text[4][3] = {
  {"1","2","3"},
  {"4","5","6"},
  {"7","8","9"},
  {"*","0","#"}
};

char Pass[5];
char master[5] = "2651";
int Pcount=0;
int XC,YC;
int PassCounter=0;
byte orient = LANDSCAPE;

void setup()
{
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.setFont(SmallFont);
  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_EXTREME);
  for(int line = 0; line <= 239; line++) // custom background color
  {
    myGLCD.setColor(0, 0, line);//text color White 
    myGLCD.drawLine(0, line, 319, line);
  }
  PassWord_makeButton();
  PassWord_buttonText();
  //RUN();
}

void loop()
{
  myTouch.read();
  int tx = myTouch.TP_X;
  int ty = myTouch.TP_Y;
  XC= constrain (map(tx, 205, 3900,0,239),0,239);
  YC= constrain (map(ty, 300, 3850,0,319),0,319);
  GetNum(XC,YC);
}

void RUN()
{
  //  while(1) // Not using the Loop() function,
  //  {
  //    myTouch.read();
  //    int tx = myTouch.TP_X;
  //    int ty = myTouch.TP_Y;
  //    XC= constrain (map(tx, 205, 3900,0,239),0,239);
  //    YC= constrain (map(ty, 300, 3850,0,319),0,319);
  //    GetNum(XC,YC);
  //  }
}

void PassWord_makeButton()
{
  for(int y = 0; y < 300;y+=100)
  {
    for(int x = 0; x < 200; x+=50)
    {
      drawButton(20+x,90+y,50+x,30+y); // this will draw the button on the screen by so many pixels
    }
  }
  return;
}

void drawButton(int x1, int y1,int x2, int y2)
{
  myGLCD.setColor(170,170,170); // grey
  myGLCD.fillRoundRect(y1-3, x1+3, y2-3, x2+3);//Button Shading 

  myGLCD.setColor(255, 255, 255); // white
  myGLCD.fillRoundRect(y1, x1, y2, x2);// outter button color

  myGLCD.setColor(200,0,0); // red
  myGLCD.fillRoundRect(y1-5, x1+5, y2+5, x2-5);//inner button color
  return;
}

void PassWord_buttonText()
{
  myGLCD.setFont(BigFont);
  myGLCD.setBackColor(200, 0, 0);
  myGLCD.setColor(255,255,255);
  for(int tr = 0; tr < 300; tr+=100)
  {
    for(int tc = 0; tc < 200; tc+=50)
    {
      char *myText = text[tc/50][tr/100];
      myGLCD.print(myText,52+tr,27+tc,0); //this will print the number into the center of the buttons
    }
  }
}

void GetNum(int tx,int ty) {
  char * lastText;
  for(int tr = 0; tr < 300; tr+=100)
  {
    for(int tc = 0; tc < 200; tc+=50)
    {
      char *myText = text[tc/50][tr/100];
      if(myTFT.TouchButton((90+tr),(20+tc),(30+tr),(50+tc),XC,YC)) // this check to see if any of the buttons were pressed, then it sends the corresponding number to the "check" function
      {
        check(*myText);
      }
    }
  }
}


void check(char pass)
{
  myGLCD.setFont(BigFont);
  Pass[Pcount] = pass;  //store incoming numbers in an array
  myGLCD.print(Pass,CENTER, 1); // show the password as it is being entered

  if(Pcount == 3)// only when the array is filled, does it check the numbers
  {
    delay(1000);
    if(!strcmp(Pass, master)) // compare the password to the master password
    {
      myGLCD.print("GOOD",CENTER, 1);
      delay(1000);
      myGLCD.print("    ",CENTER, 1);
    }
    else
    {
      myGLCD.print("FAIL",CENTER, 1);
      delay(1000);
      myGLCD.print("    ",CENTER, 1);
    }
    clearPassword(); // Clear the password
  }

  Pcount++;
  if(Pcount > 3) // this ensure the count does not exceed the maximum lenght of the password
  {
    Pcount = 0;
    PassCounter = 0;
  }
}

void clearPassword()
{
  byte i = 3;
  while(i != 0)
    Pass[i--] = NULL;
}
274  Using Arduino / Displays / Re: Help with Unknown TFT LCD on: July 15, 2014, 03:43:43 pm
What are you trying to do, because you can't remap the pins without changing the hardware.
275  Using Arduino / Programming Questions / Re: Array question on: July 15, 2014, 03:41:44 pm
Should be:
(Red[wsOut] << 16) | (Green[wsOut] << 8 ) | Blue[wsOut]
276  Using Arduino / Project Guidance / Re: Android tablet as keypad for RFID door entry on: July 15, 2014, 12:29:46 pm
With a TFT LCD display using the libraries UTFT, UTouch and my library TFT_Extension, you can do this very easily.
In fact, I even give an example keypad/password sketch.
277  Using Arduino / Project Guidance / Re: Powering mulitple Adruinos (8 to 10) - Best Source for power on: July 15, 2014, 12:22:46 pm
Take your pick, 9V Power Units
278  Using Arduino / Programming Questions / Re: Array question on: July 14, 2014, 08:55:49 pm
I agree, it is very fast but you know how to properly use DPM. But for someone who doesn't, they might go nuts trying to figure out what went wrong. I would save it until he actually gets it to work first then make it more efficient.
279  Using Arduino / Project Guidance / Re: Fireworks launch controller - Need some guidance -Total Noob here on: July 14, 2014, 06:05:14 pm
Since this forum is for arduino related questions and projects, you can use the arduino to act as a timer for special events. How much C/C++ programming experience do you have?
280  Using Arduino / Displays / Re: 1.8" TFT LCD display with an Arduino Micro on: July 14, 2014, 03:39:46 pm
All red? Ok, can you draw out a schematic of what pin(Micro) it going to the LCD.

Find this library, ST7735.h, and 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);
    }
  } 
}
281  Using Arduino / Programming Questions / Re: Array question on: July 14, 2014, 03:37:18 pm
There is also Direct Port Manipulation, where you can have control of the pins in each PORT. However this could cause issues if you are not careful. It is suggested to not be used but it is another option.
282  Using Arduino / Displays / Re: 1.8" TFT LCD display with an Arduino Micro on: July 14, 2014, 03:23:58 pm
What model LCD are you using, there are a few out there.

Can you post a picture of your wiring?
283  Using Arduino / Project Guidance / Re: Fireworks launch controller - Need some guidance -Total Noob here on: July 14, 2014, 01:00:35 pm
Quote
I'm a computer programmer
So am I but Hardware was always my first interest. Before college I wanted nothing to do with software programming, but I found out that you can't have one without the other.

I am really surprised you have little hardware knowledge, because nowadays, software and hardware go hand in hand. How do you test your software without hardware?

If you don't want a wireless solution then you can make your own button panel, and hardwire everything. (Like TNT and a Plunger) But you still need a way to provide the necessary current and I do still recommend you look into model rocket ignitors as they are easy to use and setup.
284  Using Arduino / Project Guidance / Re: Fireworks launch controller - Need some guidance -Total Noob here on: July 14, 2014, 10:26:57 am
Are you familiar with model rocket ignition systems? Using either relays or multiple H-bridges, you can turn on these ingitors and set off your fireworks.

Model Rocket Wireless Ignition
285  Using Arduino / Project Guidance / Re: WTV020-SD-mini - No sound on: July 14, 2014, 09:31:24 am
What audio format are you using WAV or AD4?
Pages: 1 ... 17 18 [19] 20 21 ... 244