Show Posts
Pages: 1 ... 48 49 [50] 51 52 ... 239
736  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 11:38:34 pm
Your welcome, I'm happy to hear my library was able to help you.

737  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 11:23:22 pm
So instead of a latching button, change it to touch button, myTFT.TouchButton(220,135,310,225);
738  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 11:14:24 pm
You need to add those at the top, they are boolean, here:

boolean last = LOW, latch = false;
739  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 11:09:57 pm
You would do it like so, put this after this line boolean button2 = myTFT.LatchButton(220,135,310,225,1);
Code:
  if (button2 != last)
  {
    latch = !latch;
    if(latch)
    {
      myGLCD.setColor(255,0,0);
      myGLCD.fillRect(220,135,310,225);// rect button 1
    }
    else
    {
      myGLCD.setColor(0,255,0);
      myGLCD.fillRect(220,135,310,225);// rect button 1
    }
  }
  last = button2;

The number in the center will still show as blue but you can disable the text by commenting it out.
I am still adding things to this library, so I will add this in it. You can follow the progress with this link.
New TFT_Extension
740  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 10:56:18 pm
? there boolean so it should be 0 and 1.

Being that my LCD and sketch uses the older library, there might be things that you need to set like text transparency.

Compare the sketch that came with the UTFT library to what I have, in my sketch. You should see text.
741  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 10:39:01 pm
This is incorrect,
Quote
UTFT myGLCD(38,39,40,41,ITDB32S);
It should be UTFT myGLCD(ITDB32S,38,39,40,41);

UTFT::UTFT(byte model, int RS, int WR,int CS, int RST, int SER)
742  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 10:28:58 pm
Nothing at all? Not even these?
Quote
myGLCD.setColor(255, 0, 0);//red box fill
  myGLCD.fillRect(0, 0, 319, 13);//text box
743  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 10:03:54 pm
Yea, try it. Look at one of the example sketches to see how to set it up.
744  Using Arduino / Programming Questions / Re: Using TFT button for dual purposes on: March 26, 2014, 08:25:51 pm
Yea, of course, but you will need a latch.

Read the coords, if the button is pressed, and not held, change the button color and state.

Here is an example you can use, but instead of an actual button, you can use the touch screen coords.
Code:
byte LEDpin = 13; //on-board LED
byte ButtonPin = 2; //digital pin 2

boolean button,last = LOW;
boolean latch = false;

void setup() {
  pinMode(LEDpin, OUTPUT);
  pinMode(ButtonPin, INPUT);
}

void loop()
{
  button = digitalRead(ButtonPin);
  if (button == HIGH && button != last)
  {
    latch = !latch;
    latch ? digitalWrite(LEDpin, HIGH): digitalWrite(LEDpin, LOW);
  }
  last = button;
}

Or if you want, you can download my TFT library, where I have already done just that.
TFT_Extension.zip

You may need to change the libraries in my example sketches. I have the old ITDB02 libraries, but my TFT library should work with the ones you have. If not, then let me know and I'll tell you what to fix to get it to work.
745  Using Arduino / Project Guidance / Re: Wristwatch with four buttons and Nokia 5110 on: March 26, 2014, 05:56:39 pm
@raschemmel

Those might be a little too big to fit into a watch, he might want these instead.
Mini tactile buttons.
746  Using Arduino / Project Guidance / Re: Hi new to this wonderful new World of Arduino. on: March 26, 2014, 05:52:47 pm
Do any of the servo need to move at the same time, because you can probably multiplex them to save pins.
Also yes it can be done wirelessly with two Arduinos. You can use RF, bluetooth, Xbees, and/or IR, but either way you will need another Arduino as a controller.

You will need a power supply capable of supplying enough current to all the servos and the possibly the Arduino too.

747  Using Arduino / Project Guidance / Re: Wristwatch with four buttons and Nokia 5110 on: March 26, 2014, 05:29:07 pm
You might be in a little too far over your head with this project. Its easy to do with breadboards and wires, but for something to look like a wristwatch and still function, that's a little much.
 
All  those parts might stick out a little too far, so if you want to keep things compact, you might want to get bare components.

Find out where you can get the ATmega168 chip without a board so you can make your own PCB, then see if you can find a low power LCD. I'm not sure if that Nokia LCD will work with 3.3V or if it needs 5V. These are things you need to research and plan out. For buttons, you can try to get some mini tactile buttons online, costs may vary so shop around.

As always, start with regular components first and get it to work.

EDIT, I took to long -_-
748  Using Arduino / Programming Questions / Re: Slight discrepancy in my code, where am i going wrong? on: March 26, 2014, 05:05:49 pm
Ok, well what you could do is if the button is pressed and held, then you can have a counter increase from 0 to 99. OR you can have the code check to see if the button is pressed for a certain amount of time, say 2 seconds. Then if the button is held down for 2 seconds then you can run the stepper 100 steps and set a flag. Once the stepper is done, the flag is set and the button is released, you can step in the other direction until that is done.

Here is a sketch to get you started.
Code:
const byte buttonPin = 2;     
const byte ledPin =  13;

boolean buttonState = 0;
boolean  lastReading = 0;
boolean Released = false;
long onTime = 0;

void setup() {
  pinMode(ledPin, OUTPUT);     
  pinMode(buttonPin, INPUT);     
}

void loop(){
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH && lastReading == LOW) // first check to see if the button is pressed ie. HIGH and it is different from lastReading
  {
    onTime = millis(); // record time
    lastReading = HIGH; // prevents the code from entering this IF statement, until lastReading is set to LOW again.
  }

  if (buttonState == HIGH && lastReading == HIGH) // button is still held down
  {
    if ((millis() - onTime) > 3000) // check to see if button is held down for 3 seconds
    {
       Released = false; // button is still being held down.
      // Clockwise 100 steps here
      digitalWrite(ledPin, HIGH); // if button is held down for 3 seconds, LED on
    }
    else
    {
      digitalWrite(ledPin, LOW); // otherwise LED remains off
    }
  }

  if(buttonState == LOW && Released == false) //check to see if the button is LOW and was released, then start over.
  {
       // counterclockwise 100 steps
       lastReading = LOW;
       Released = true;
   }
}

You will need to add another boolean variable here to lock out this part after the stepper does its 100 steps, otherwise it will keep stepping.
749  Using Arduino / Programming Questions / Re: Slight discrepancy in my code, where am i going wrong? on: March 26, 2014, 04:22:36 pm
Quote
despite the code quite clearly specifying to only to move 100 steps
Actually your code is constantly being told to do 100 steps, regardless if the button is pressed or not.

What exactly do you want it to do?
750  Using Arduino / Programming Questions / Re: Making this code more efficient and smaller... Possible? on: March 26, 2014, 04:00:07 pm
No sorry, at first I thought I saw both lines saying tempArray[0], because I saw "te" and "Array[0]", it wasnts until I posted my reply did I notice that one was tempArray and the other was textArray. After that, I removed it.
Pages: 1 ... 48 49 [50] 51 52 ... 239