Show Posts
Pages: 1 ... 52 53 [54] 55 56 ... 243
796  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
797  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.
798  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)
799  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
800  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.
801  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.
802  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.
803  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.

804  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 -_-
805  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.
806  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?
807  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.
808  Using Arduino / Programming Questions / Re: Making this code more efficient and smaller... Possible? on: March 26, 2014, 03:11:38 pm
@holmes4
That part of the code is only done once. Its a lock out, so its not really slowing down his code.

What puzzles me is this why didn't the OP just put that in his setup function.
Edit.
809  Using Arduino / Project Guidance / Re: Arduino + Color Sensor + Lock mechanism on: March 25, 2014, 05:43:33 pm
I have this code that works with a color sensor and a servo that you might be able to use. Note: this code uses blocking delays, so you will need to change them to use the millis function. (If need, that is)

Code:
int s0=3,s1=4,s2=5,s3=6;
int flag=0;
int counter=0;
int countR=0,countG=0,countB=0;
void setup()
{
  Serial.begin(115200);
  pinMode(s0,OUTPUT);
  pinMode(s1,OUTPUT);
  pinMode(s2,OUTPUT);
  pinMode(s3,OUTPUT);
}
void TCS()
{
  digitalWrite(s1,HIGH);
  digitalWrite(s0,LOW);
  flag=0;
  attachInterrupt(0, ISR_INTO, CHANGE);
  timer2_init();
}
void ISR_INTO()
{
  counter++;
}
void timer2_init(void)
{
  TCCR2A=0x00;
  TCCR2B=0x07; //the clock frequency source 1024 points
  TCNT2= 100;    //10 ms overflow again
  TIMSK2 = 0x01; //allow interrupt
}
int i=0;
ISR(TIMER2_OVF_vect)//the timer 2, 10ms interrupt overflow again. Internal overflow interrupt executive function
{
  TCNT2=100;
  flag++;
  if(flag==1)
  {
    counter=0;
  }
  else if(flag==2)
  {
    digitalWrite(s2,LOW);
    digitalWrite(s3,LOW);
    countR=counter/1.051;
    Serial.print("red=");
    Serial.println(countR,DEC);
    digitalWrite(s2,HIGH);
    digitalWrite(s3,HIGH);   
  }
  else if(flag==3)
  {
    countG=counter/1.0157;
    Serial.print("green=");
    Serial.println(countG,DEC);
    digitalWrite(s2,LOW);
    digitalWrite(s3,HIGH);
  }
  else if(flag==4)
  {
    countB=counter/1.114;
    Serial.print("blue=");
    Serial.println(countB,DEC);
    digitalWrite(s2,LOW);
    digitalWrite(s3,LOW);
  }
  else
  {
    flag=0;
    TIMSK2 = 0x00;
  }
  counter=0;
  delay(2);
}
void loop()
{
  delay(10);
  TCS();
  if((countR>10)||(countG>10)||(countB>10))
  {
    if((countR>countG)&&(countR>countB))
    {
      Serial.print("red");
      Serial.print("\n");
      delay(1000); // give time for the servo to move to its correct location.
    }
    else if((countG>=countR)&&(countG>countB))
    {
      Serial.print("green");
      Serial.print("\n");
      delay(1000);
    }
    else if((countB>countG)&&(countB>countR))
    {
      Serial.print("blue");
      Serial.print("\n");
      delay(1000);
    }
  }
  else
  {
    // Do something here otherwise
    // delay(1000);       
  }
}
810  Using Arduino / Project Guidance / Re: Displaying two analog gauges onto an LCD screen. on: March 25, 2014, 05:39:42 pm
A case? not that i'm aware of, you will have to check the site that sells them. If anything you will need to make your own case too.
Pages: 1 ... 52 53 [54] 55 56 ... 243