Show Posts
Pages: 1 ... 38 39 [40] 41 42 ... 229
586  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)
587  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
588  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.
589  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.
590  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.
591  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.

592  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 -_-
593  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.
594  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?
595  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.
596  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.
597  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);       
  }
}
598  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.
599  Using Arduino / Project Guidance / Re: Displaying two analog gauges onto an LCD screen. on: March 25, 2014, 05:28:07 pm
Yea its possible but you wont be able to write it in java, it will need to be in C/C++.

Quote
Can data be read from the input at a rate of 500ms, possibly faster?
It can read the data a lot fast then that if you need it to.

Quote
What are the limitations of the video out? I'm thinking of using composite out.
You may want to look into the TVOut library, but it wont be in color. Or you can get a TFT lcd and make your own interface. I have a code that already allows you to make a working gauge, but it will require you to have a TFT that uses the UTFT graphics library.
600  Using Arduino / Programming Questions / Re: Question 433mhz transmitter and receiver. on: March 24, 2014, 10:05:23 pm
This should be better. Instead of "debouncing" the button, I changed it to lockout the button if it remains pressed. This should insure a better toggle on the receiving end.

Code:
#include <VirtualWire.h>

byte ButtonState[4];
byte lastState[4] = {
  LOW};
unsigned long oldTime[4] = {
  0,0,0,0};
byte myButtons[4] = {
  8,9,10,11};

void setup() {
  Serial.begin(115200);      // Debugging
  Serial.println("setup");

  // inisial IO dan ISR
  vw_set_ptt_inverted(true); // dibutuhkan untuk DR3100
  vw_setup(2000);     // Bits per sec
  vw_set_tx_pin(3);

  for(byte i = 0; i < 4; i++)
    pinMode(myButtons[i], INPUT);

  pinMode(13, OUTPUT);
}

void loop()
{
  char *msg = "0"  ;

  if(debounce(0))
  {
    msg = "1";
    Serial.println("1");
    digitalWrite(13, true);
  }
  if(debounce(1)){
    msg = "2";
    Serial.println("2");
    digitalWrite(13, true);
  }
  if(debounce(2))
  {
    msg = "3";
    Serial.println("3");
    digitalWrite(13, true);
  }
  if(debounce(3))
  {
    msg = "4";
    Serial.println("4");
    digitalWrite(13, true);
  }

  vw_send((uint8_t *)msg, strlen(msg));
  vw_wait_tx();
  digitalWrite(13, false);
}

boolean debounce(byte Button)
{
  boolean Output = false;

  ButtonState[Button] = digitalRead(myButtons[Button]);

  if(ButtonState[Button] == HIGH && ButtonState[Button] != lastState[Button])
  {
    Output = true;
  }
  
  lastState[Button] = ButtonState[Button];
  return Output;
}
Pages: 1 ... 38 39 [40] 41 42 ... 229